我正在为一个单页网站使用WordPress安装。我正在使用'query_post'数组获取所有内容。对于每个页面部分,它会创建一个id为#content的div。使用PHP添加CSS-class
<?php query_posts('post_type=page&order=ASC'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="content">
<div id="inner-content" class="wrap cf">
<div id="main" class="m-all">
<h2><?php the_field('headline') ?></h2>
<div class="sidebar"><?php the_field('sidebar') ?></div>
<div class="main-content"><?php the_content(); ?></div>
</div>
</div>
</div>
<?php endwhile; endif; ?>
我现在想要做的是根据顺序为每个页面部分添加一个特定的ID。类似于
<div id="content section-1">...</div>
<div id="content section-2">...</div>
<div id="content section-3">...</div>
等等。我如何修改我的代码来实现这一目标?
我认为你的代码有问题:id不是类;) – Masiorama 2015-02-11 08:30:04
除了上面的内容,你应该使用'counter' – rnevius 2015-02-11 08:35:38
哦,天啊!内容ID正在被复制。 :O:O – 2015-02-11 08:38:47