我试图在主页的侧栏中显示一个自定义小部件(这是中定义的静态首页Settings > Reading). 以下是我的sidebar.php:
if ( is_front_page() || is_home() ) {
if ( is_active_sidebar( \'sidebar_lecture\' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( \'sidebar_lecture\' ); ?>
</div>
<?php
endif;
侧栏不会显示,因为条件标记无法将我的主页识别为主页。
当我print_r($wp_query) 在侧栏中,它显示[is_page] => 1 这篇文章[ID] => 32, 这是正确的。然而[is_home] 为空。
作为记录,我确实使用了自定义查询(query_posts()) 在我的page.php 模板,但我后来用wp_reset_query().
有什么指示吗?