WordPress.org

Ready to get started?Download WordPress

Forums

different sidebar items for different pages (6 posts)

  1. bongkph
    Member
    Posted 8 years ago #

    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.

  2. ZMAng
    Member
    Posted 8 years ago #

    Refer to the appropriate WordPress codex article on this.

  3. Bryan Davis
    Member
    Posted 8 years ago #

    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.

  4. bongkph
    Member
    Posted 8 years ago #

    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:

  5. Our Location
  6. Email Form
  7. Telephone & Fax Numbers
  8. 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.

  • pizdin_dim
    Member
    Posted 8 years ago #

    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".

  • bongkph
    Member
    Posted 8 years ago #

    ok thanks, i will try that.

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags