Forums

[resolved] Dynamic exclude a id from wp_list_pages (3 posts)

  1. rasmuscarlsen
    Member
    Posted 2 years ago #

    Greetings all!

    Just read this guide on wp_list_pages and thats great - I managed to do it! ;-)

    Anyway; what I need to do is dynamicly excluding a page from the list.

    Lets say I got 5 pages, alle the same (special) template and they all have the same parent - and the same (special) sidebar.

    On the sidebar I want a list of all the pages using that template and/or having the same parent - but just nok the page that is beeing viewed ... I dont want the parent-page ind the list.

    Does it make sense?

    thanks

    rasmus

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    Something like this in your sidebar.php

    <?php
    if (is_page()) {
    $page = $post->ID;
    $exclude = $page;
    wp_list_pages('title_li=<h2>Pages without the currently view page/tree</h2>&exclude_tree='.$exclude );
    }
    ?>
  3. rasmuscarlsen
    Member
    Posted 2 years ago #

    Yeah! Thats it. Thanks!

    ras

Topic Closed

This topic has been closed to new replies.

About this Topic