Support » Fixing WordPress » 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.

Viewing 5 replies - 1 through 5 (of 5 total)

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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘different sidebar items for different pages’ is closed to new replies.