WordPress.org

Support

Support » How-To and Troubleshooting » How to make different pages show different widgets.

How to make different pages show different widgets.

  • I am creating a website with static pages and I would like to somehow customize the widgets differently for different sections of the website. I would like to create pages that will have different links in the sidebars than the rest of the website.

    From the main website there will be a link to the main page for that section. Then that page will have links to all of it’s child pages. But I only want those links to show up on that page and it’s child pages but not on the rest of the website.

    Is there a way to do this? Preferably a way without writing code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Well, you’ll have to do SOME code writing:

    I imagine your widgets are in your sidebar, or some other file; setup collections of those widgets and write 2, 3, 4, etc. separate files for those collections.

    Where you want them to appear, use the php tag
    <?php include ('widgets_collection1.php'); ?> where “widegets_collection1.php” is the file names you named those collections.

    This is the least code-intensive way; not the cleanest, but the least code-intensive way.

    Your other option is to include the widgets in if(is()) statements:
    E.g.

    <?php if ( is_page('N') ) { ?>
    
    -------------
    Code for your widgets
    -------------
    } ?>

    where N in the is_page() is the page id in the CMS.

    I recommend the include() option.

    Cheers.

    Justin Tadlock

    @greenshady

    WordPress God

    Let’s not overly complicate things here. You don’t have to write ANY code to do this.

    Here are a couple of plugins that allow you to dynamically show widgets:
    http://wordpress.org/extend/plugins/widget-logic
    http://konstruktors.com/blog/wordpress/842-wordpress-gpl-widget-context-plugin

    Then, if you need better widgets, try out the Widgets Reloaded plugin, which will give a lot more widget settings:
    http://wordpress.org/extend/plugins/widgets-reloaded

    OK. Maybe I lied just a little about not having to use any code. If you use the Widget Logic plugin, you’ll have to use conditional tags, but I would hardly call this coding. No coding is required with Widget Context though.

    Thanks for that. The plugin might be what I need. There is another option that might work that I saw on Youtube that might be even more simple but I don’t know how to make it work. The guy was showing that on his “pages” widget a main page would show up on the list and so would it’s child and the childs child. But any more subpages wouldn’t be on the list. But on my list it doesn’t do that it will show sub pages many levels deep. Is there a way to change the settings so it will only show a child or 2 deep?

    I use a plugin called “Slayer’s Custom Widgets”.

    It does what you describe.

    thanks a lot. great help

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to make different pages show different widgets.’ is closed to new replies.
Skip to toolbar