您好,欢迎光临! 推荐您使用Chrome浏览器访问本站。

非插件调用 WordPress 置顶文章列表

调用 WordPress 置顶文章列表:

在需要调用 WordPress 置顶文章的地方直接添加以下代码即可:


<ul>
<?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(); ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
</ul>

您可能也喜欢