• Resolved Spencer Hill

    (@ws5f3dj7)


    Hey – so I have some sub-navigation that I want only to appear on certain pages. Is there a way to tell the navigation to show and hide depending on the page?

Viewing 4 replies - 1 through 4 (of 4 total)
  • You may want to set up two sets of navigation code in an if – else statement, and execute the one without the subnav on the pages on which you want to hide the subnav. You could possibly set a custom field on those pages (all such pages using the same key) and test

    if custom field = “no-subnav” then
    this wp_list_pages()
    else
    that wp_list_pages()
    end

    Thread Starter Spencer Hill

    (@ws5f3dj7)

    So basically I just need to write my own ifelse statement, there’s no WP standard way of doing this?

    I’m not thinking offhand of any built-in WP way to do this. Someone else may have another suggestion

    The code that’s needed is pretty simple.

    Thread Starter Spencer Hill

    (@ws5f3dj7)

    Okay, yeah, here’s what I ended up writing just in case someone is looking for this same solution which I placed inside the <body> tags of my index.php file:

    if ($_SERVER[‘REQUEST_URI’] != ‘/clean-url’) {
    echo ‘
    <style type=”text/css”>
    .example {
    display: none;
    }
    </style>
    ‘;
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do you hide sub navigation except on certain pages?’ is closed to new replies.