[resolved] Include the excluded pages (4 posts)

  1. andyhoyland
    Posted 8 years ago #

    Hi all...

    I was wandering (or wondering...) if it is possible to sometimes include the pages that I have excluded from my sidebar. So for example, on my index page I want to exclude pages 2,3,4 and 5 BUT if someone finds page 2 (via a different link I have set up) I would like them to be able to see links to pages 3,4 and 5 in the sidebar on page 2.

    Should I do this (and indeed, can I do this!) by setting up a sidebar for the excluded page? So page 2 has a different sidebar to my index page?!

    Did that make sense?!

    Hope so and thanks for any help.
    PS The site I am working on is http://www.stjb.org.uk - at the moment I use the very lovely Fold Page List and like the way it works but want to get rid of some pages in the sidebar!

  2. peiqinglong
    Posted 8 years ago #

    PHP will do what you want. I believe the answer can be found here: http://codex.wordpress.org/Conditional_tags

  3. Kafkaesqui

    Posted 8 years ago #

    No extra sidebar needed (unless you really want that sort of thing). Just replace your current call to wp_list_pages() with this:

    global $post;
    if(2 != $post->ID) {
    $exclude = '2,3,4,5';

    What this does is make sure the $post object is available, then tests to see if 2 is the value for the Page ($post) ID. If it isn't, the $exclude var is populated with the Page IDs to exclude. This var (with or without the IDs) is then provided as the value to the 'exclude' parameter.

    EDIT: Solution based on peiqinglong's pointer...

    if( is_page(2) ) {
    } else {

  4. andyhoyland
    Posted 8 years ago #

    Great - thanks for that... it worked on my development version! Just need to try it on the full site now!

    Thank you guys.

Topic Closed

This topic has been closed to new replies.

About this Topic