【发布时间】:2018-08-03 02:04:10
【问题描述】:
试图在我的客户主页上显示一个英雄区域显示最近的置顶帖子,但我似乎一直遇到障碍。代码末尾的错误使我在死亡时得到白屏。这是我的代码:
<?php if (is_home()) {
$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(); ?>
<div class="trend-post">
<div class="thumb"><?php the_post_thumbnail(); ?></div>
<div class="title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></div></div>
<?php endwhile;?>
<?php wp_reset_query()?>
}
?>
【问题讨论】:
-
wp_reset_query()后面少了一个分号。另外,您是否尝试将define( 'WP_DEBUG', true );添加到您的 wp-settings.php 文件以启用错误报告?
标签: php wordpress sticky website-homepage