所以我用的是tags.php
在我的WordPress网站上创建特色页面;我想做的是在包含前五篇文章的每个页面的索引上创建一个特色区域。
我在主页上有一个类似的特色区域,使用粘性帖子;但在这种情况下,我只想将前五篇帖子放在特色循环中,然后将其余帖子放在普通循环中。
我尝试了很多谷歌搜索和查看WordPress文档,但都失败了。以下是我用于特色区域的代码:(但是,如果我尝试将其放在标记页面上,它只会创建另一个主循环)
<?php if(is_home() && !is_paged()) { ?>
<?php query_posts(array(\'post__in\'=>get_option(\'sticky_posts\'))); ?>
<?php while (have_posts()) : the_post(); ?>
<article class="sticky">
<div class="desc">
<h2 class="header">Featured Post:</h2>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content(\'\'); ?>
<ul class="post-info">
<li><?php the_time(\'jS F Y\'); ?></li>
<li>Posted in <?php the_category(\', \'); ?></li>
<li><a href="<?php the_permalink(); ?>#comments"><?php comments_number(\'No Comments\', \'1 Comment\', \'% Comments\' );?></a></li>
</ul>
</div>
</article>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<?php } ?>