WordPress调用置顶文章是常用的调用代码,码笔记分享WordPress调用置顶文章代码:
WP调用置顶文章代码
以下代码为调用5篇置顶文章:
1 2 3 4 5 6 7 8 9 10 |
<?php $sticky = get_option('sticky_posts'); rsort( $sticky ); $sticky = array_slice( $sticky, 0, 5); query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) ); if (have_posts()) : while (have_posts()) : the_post();?> <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endwhile; endif; ?> //码笔记:调用置顶文章代码 |
默认为调用5篇置顶文章,您可以修改$sticky, 0, 5
中的数字来自定义调用置顶文章数量。
2023云服务器降价了!阿里云VS腾讯云
阿里云:2023阿里云服务器价格便宜到家了(值得买)
腾讯云:2023腾讯云2核4G服务器8M带宽70元一年(多配置可选)
华为云:2023华为云优惠活动云服务器60元一年起(查看更多配置报价)
免费提供技术支持: 咨询客服
发表评论