0

I am building a wordpress website and I want to show a text widget in the footer just for one page template. That widget shouldnot be seen for other pages. Is there any possible way for that?

3 Answers 3

3

There are a couple of options:

  1. Use a Plugin that adds contextual conditions to Widgets
  2. Only output the dynamic_sidebar() in the page template in question. For example, if your custom page template is named template-foobar.php, and the dynamic sidebar name is footer-text-widget:

    if ( 'template-foobar.php' == get_page_template() ) { 
        dynamic_sidebar( 'footer-text-widget' ); 
    }
    
0

Building on @Chip's answer, if you want to go down the plugin route, I sometimes use one called 'Custom Sidebars' (somewhat conveniently).

You'll be able to create your own sidebar (Appearance -> Custom Sidebars), and then add widgets to it (Appearance -> Widgets).

Then, you'll need to go to the page in question (Pages -> All Pages -> [Your Page]), and look for a new box called Sidebars that lets you select the sidebar you just created.

0

Use a filter, example:

function remove_the_widget( $regions ){
    if(is_page('12')) {
        $key = array_search('text-3', $regions['sidebar']);
        if($key !== FALSE) {
            unset($regions['sidebar'][$key]);
        }
    }
    return $regions;
}
add_filter('sidebars_widgets', 'remove_the_widget');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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