定制器添加部分参数 'active_callback' => "is_front_page" 不工作

Customizer Add Section argument 'active_callback' => "is_front_page" not working

我正在为我的主题设置定制器。我拥有我需要的所有部分和控件,但现在我正试图让其中一些只显示在特定页面上。

我的第一站是仅与主页相关的部分。我读到 here 我可以添加一个名为 "active_callback" 的参数 tp arguments 对象并传递给它一个检查函数,例如 is_front_pageis_home.

看起来很简单,直到我尝试了它,但它没有用。我已经尝试了所有我能想到的(这是我第一次涉足 WordPress),所以现在我来找你们希望你们能回答我的问题

我正在 functions.php 中自定义定制程序,如下所示:

add_action( 'customize_register', 'ablogs_theme_customizer' );
function ablogs_theme_customizer($wp_customize) {
     $wp_customize->add_section( 'home-page-slider-settings', array(                                             
           'title'          => "Slider Settings",
           'priority'       => 0,
           'active_callback' => 'is_front_page'
     ));
}

如果我取消活动回调参数,它显示得很好,但在自定义时显示在每个页面上。我真的需要它只显示在主页上。我没有使用静态首页。我是 运行 一个自定义的 front-page.php 文件,它充当首页,所以我猜想在检查这些值时它应该算作 front-pagehome,两者我试过了。

谁能帮帮我

问题是我有多个循环,每个循环在首页上都有不同的查询。确保每次都重置它们后,此问题自行解决。

例如,我的新查询和循环如下所示:

query_posts( array(
    'category_name'=>"Cloud, Customer Engagement, Developers, Executive Thought Leadership, Networking, Services, Solutions, Team Engagement",
    'showposts'=>8,
    'order'=>DESC
));

// Start the loop
if ( have_posts() ) : while ( have_posts() ) : the_post();

    echo '<div class="post-card-wrap">';

        // Get the card
        get_category_post_card($post);

    echo '</div>';

// End the loop
endwhile; endif;

// Reset the query
wp_reset_query();