wordpress中如何调用置顶文章
摘要:wordpress中如何调用置顶文章
wordpress中如何调用置顶文章
1.找到你需求显示置顶文章的代码地位,插入如下代码:
<?php
$sticky = get_option('sticky_posts');
rsort( $sticky );
$sticky = array_slice( $sticky, 0, 5);
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1,'showposts' => 4,'cat' =>5) );
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
显示内容代码,可能本人设置。
<?php endwhile; ?>
<?php else : ?><p class="center">没有数据。</p>
<?php endif; ?>
2.调整显示内容的代码样式等