将下面的代码添加到主题 archive.php 或者 category.php 模板主循环上面:
- <?php
- query_posts(array(
- "category__in" => array(get_query_var("cat")),
- "post__in" => get_option("sticky_posts"),
- 'showposts' => 3,
- )
- );
- while(have_posts()) : the_post();
- ?>
- <h1>置顶<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
- <?php
- endwhile;
- wp_reset_query();
- ?>
其中: 'showposts' => 3, 是显示数量。
答案内容来自知更鸟
如若转载,请注明出处:https://www.ozabc.com/jianzhan/342704.html