我需要在“循环”之外的部分显示“粘性”帖子。
有人能告诉我怎么做吗?
我需要在“循环”之外的部分显示“粘性”帖子。
有人能告诉我怎么做吗?
我正在使用此查询;
<?php
$sticky = get_option( \'sticky_posts\' ); // Get all sticky posts
rsort( $sticky ); // Sort the stickies, latest first
$sticky = array_slice( $sticky, 0, 1 ); // Number of stickies to show
query_posts( array( \'post__in\' => $sticky, \'caller_get_posts\' => 1 ) ); // The query
if (have_posts() ) { while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php endwhile;?>
<?php } else { echo ""; }?>
希望它对你也有用……) $last_sticky_post = get_post(end(get_option(\'sticky_posts\')));
if(!empty($last_sticky_post)):
setup_postdata($last_sticky_post);
the_title(); // standard loop here...
the_content();
endif;
(这是一篇文章)使用get_posts() 使用\'include\' => implode(\',\', get_option(\'sticky_posts\'))
参数来获取所有粘性帖子(Martin的解决方案没有array\\u slice也会这样做)。
我切换到了另一个主题,并决定用其中的一些默认代码制作一个小部件,在自定义循环中显示我的美味帖子、推特帖子、su帖子和youtube视频(不包括主循环中的这些类别)。但是现在。。。分页不再工作。我制作了这个小部件:// =============================== EDL Sidebar Posts Widget ====================================== class SidebarPosts extends WP_Widget { &#x