different sidebar items for different pages
-
Hi, I am doing a company website layout where main menu is on top and submenu should be on the sidebar. Typically sidebar contents will be based on what pages I am in. For example when I go to Company Profile Page I can see a submenu on sidebar such as About Us, Investors Relation, Profile etc… and so as to other pages. Can someone help me. Thanks.
-
Refer to the appropriate WordPress codex article on this.
Are the pages for the sidebar “children” of the current page? If so, you can list them as such. Check out this page in the Codex.
Thanks for the info. However. My sidebar contains only submenu (links) example. If I am on Contact Us page. I would like to have on sidebar:
- Our Location
- Email Form
- Telephone & Fax Numbers
Wherein Our Location, Email Form and Telephone are wordpress pages that I want to call.
Obviuously, when I am on “About Us” page the above links should not appear instead a link calling the pages necessary for “About Us”
I will not be using the default sidebar contents such as category, archives, login and feed.
Although I haven’t done it, I believe this should work if placed in your sidebar:
<?php
if (is_page()) {
$post = $posts[0];
$key = $post_meta_cache[$post->ID]['key'];
switch (strtolower($key)) {
case 'about':
// echo the relevant links to the about page
case 'products':
// echo the relevant links to the products page
case 'services':
// echo the relevant links to the services page
case 'contact':
// echo the relevant links to the contact page
}
}
?>
That”s assuming you”ve got four pages, each with their own custom field having a key of “key” and a value of “about”, “products”, “services” and “contact”.
ok thanks, i will try that.
The topic ‘different sidebar items for different pages’ is closed to new replies.