Different sidebar menus for given pages
-
Is it possible to have a page come up showing a different sidebar set-up, such as a custom menu for that particular page?
Thanks
-
Yes, there are several ways to do this. One way is to use WordPress conditionals in your theme files and create separate sidebars or other included files.
Just for example:
<?php if (is_page('about-us')): get_sidebar('about'); // get the default sidebar else: get_sidebar(); endif; ?>That means “if the page slug is about-us include the file called sidebar-about.php, otherwise include the default sidebar.php file.”
Reference: http://codex.wordpress.org/Function_Reference/get_sidebar
Whoa… that’s cool. I got a feeling it will tax my brain to make it work, but it looks like exactly what I wanted.
Also looks like a good way to screw up.Should the code you put there go in the sidebar?
Thank you.
No, I think I see that it goes in the main index template.
Or would it be the page template?
Also, my theme has both left and right sidebars. Would I specify the special menu sidebar to the right just by stating rsidebar.php as the default in the code you showed me?
Thanks again
It goes in the page template – whichever one applies. For example, page.php for pages, single.php or index.php or archive.php or category.php (or others) for posts. It depends what you’re trying to accomplish.
Also, my theme has both left and right sidebars. Would I specify the special menu sidebar to the right just by stating rsidebar.php as the default in the code you showed me?
You’ll need to replace whatever relevant sidebar include code is in your relevant template file currently – either right or left, again depending what you’re trying to do.
Whoa, It worked!!! That’s SO cool. And I learned about changing slugs…which is the same as changing permalinks, right?
Thanks so much
Lin
Awesome! Glad it worked out.
And I learned about changing slugs…which is the same as changing permalinks, right?
Very close. Technically, the permalink is the entire URL, and the slug is the bit between the last two slashes. More info: http://codex.wordpress.org/Glossary#Slug
OK this is driving me nuts
I included this code in the page.php template
<?php if (is_page('star-contributors')): get_sidebar('star'); // get the default sidebar else: get_sidebar(); endif; ?>The page I want to carry the conditionsl sidebar is star-contributors.php
The files sidebar-star.php exists. It includes contribs-vd.phpThey are there on the directory. But I can’t get it to anything other than tell me they don’t exist.
I just want certain pages to carry their own sidebar menus.
Can somebody help me further with this?
ThanksVery few people will look at a topic marked ‘Resolved’. You should start a new thread with your last question if it is not solved.
The topic ‘Different sidebar menus for given pages’ is closed to new replies.