WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to register a test sidebar and have to include it on a specific page. On registering sidebar as

register_sidebar(array('name' => 'ABC'));

Additional banners get displayed on all pages. Previously there are 4 dynamic sidebars registered and PHP Code is related with them (banner html). Before relating any banner with the newly created sidebar, I got them displayed. Anyone have an idea from where it get wronged?

share|improve this question
In order to answer your question more specifically, we really need to see the actual code you've used. – Chip Bennett May 7 '12 at 19:58

You have three options:

  1. Register a dynamic sidebar for a specific page, and then create a page template that calls dynamic_sidebar() for the registered sidebar.
  2. Use an is_page( $id ) conditional wrapper in your page.php template
  3. Output Widget code conditionally, using is_page( $id )

Custom Page Template

The first option would include your register_sidebar() call in functions.php:

register_sidebar( array(
    'name' => 'Specific-Page Sidebar',
    'id' => 'specific-page-sidebar'
    // other array parameters omitted for brevity
) );

Then, you create a custom page template, e.g. template-test-sidebar.php.

Then, in the appropriate place in the custom page template, invoke the specific sidebar, via dynamic_sidebar():

dynamic_sidebar( 'specific-page-sidebar' );

is_page() conditional in page.php

The second option is more simple, but less dynamic, as it requires you to hard-code the page ID into the template. Simply wrap dynamic_sidebar() in an is_page() conditional:

if ( is_page( $id ) ) {
    dynamic_sidebar( 'specific-page-template' );

Conditional Widget Output

The third method involves conditional output of the Widget itself, which generally requires use of a Plugin, such as Widget Logic or any of several other related Plugins.

With this method, you don't need to register a separate dynamic sidebar. You simply use one of your existing sidebars, and then the Plugin provides an in-Widget option to specify the conditional logic to use, such as is_page( $id ) to determine if the Widget should be displayed.

share|improve this answer
Thanks for the detailed reply. In any case i need to register a sidebar register_sidebar( array( 'name' => 'Specific-Page Sidebar', 'id' => 'specific-page-sidebar' // other array parameters omitted for brevity ) ); and on registering it, I got the additional banner code visible. Is it possible that a sidebar is registered but not called (i.e. dynamic_sidebar is not being used) and it effect the page display? – Sidra Sultana May 7 '12 at 20:50
I'm not sure I understand your question...? – Chip Bennett May 7 '12 at 20:59
I think you're leaving out some important info in your question. At first is seemed you wanted a sidebar that will only show on a certain page and not others. Both Chip and I have offered examples of how to do that. What is the "Mystery" event that will trigger this sidebar/banner? Maybe if we knew we could help. Regards, – Jeremy Jared May 7 '12 at 21:57

A simple conditional statement will ensure it shows on a single page only. Your question is a little hard to follow, so I'm not sure that's exactly what you need. If you want the sidebar shown, but not the banner unless added, and then and only then it shows on a single page you should clarify your question.

To include the sidebar or widget on a single page use this from sidebar.php:

<?php if ( is_page( 890 ) )  if ( ! dynamic_sidebar( 'top-sidebar' ) ) : endif; ?>
share|improve this answer
ya I know that dynamic_sidebar is used to show the content of sidebar but what if I only register a sidebar and the content got visible without loading the sidebar (through dynamic_sidebar function) – Sidra Sultana May 7 '12 at 17:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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