WordPress分类列表页怎么置顶本分类文章?

其实旅行最大的好处,不是能见到多少人,见过多美的风景,而是走着走着,在一个际遇下,突然重新认识了自己。

将下面的代码添加到主题 archive.php 或者 category.php 模板主循环上面:

  1. <?php
  2. query_posts(array(
  3. "category__in"=>array(get_query_var("cat")),
  4. "post__in"=>get_option("sticky_posts"),
  5. 'showposts'=>3,
  6. )
  7. );
  8. while(have_posts()):the_post();
  9. ?>
  10. <h1>置顶<arel="nofollow noopener noreferrer" href="<?phpthe_permalink();?>"title="<?phpthe_title();?>"><?phpthe_title();?></a></h1>
  11. <?php
  12. endwhile;
  13. wp_reset_query();
  14. ?>

其中: 'showposts' => 3, 是显示数量。

答案内容来自知更鸟

以上就是WordPress分类列表页怎么置顶本分类文章?。高标准,精细化,零缺陷。更多关于WordPress分类列表页怎么置顶本分类文章?请关注haodaima.com其它相关文章!

您可能有感兴趣的文章
WordPress站点Gravatar头像前后台不显示的如何解决办法

WordPress主题需要支持https吗?WordPress站点如何如何实现https?

WordPress站点的页面/标签/分类URL地址如何添加.html?

WordPress站点更换了域名后数据库应该如何操作替换新旧域名?

WordPress安装在主机空间的什么目录里面?根目录在哪里?