1

I am working on setting up the customizer for my theme. I have all of the sections and controls I need, but now I am trying to make some of them only show on certain pages.

My first stop is the sections that relate only to the home page. I read here that I can add an argument called "active_callback" tp the arguments object and pass it a check function such as is_front_page or is_home.

Seemed easy, until I tried it and it didn't work. I've tried everything I could think of (this is my first foray into WordPress), so now I am coming to you all hoping you can answer my question

I am customizing the customizer in functions.php like such:

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'
     ));
}

If I take off the active callback argument, it shows up just fine, but on every page while customizing. I really need this to only show up on the home page. I am not using a static front page. I am running a custom front-page.php file that acts as the front page, so I am guessing that should count as both front-page and home when checking for those values, both of which I have tried.

Can anybody help me out here

2

The problem was I had multiple loops that each had different queries on the front page. After making sure to reset them each time, this problem resolved itself.

For instance, my new query and loop looks like this:

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();
0

Replace your code with this code: FOR MORE INFO

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'   => 'callback_single'
     ));
} 

function callback_single() { return is_home(); }

NOTE: Just try it. code is not tested. hope it's working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.