Support » Themes and Templates » wp_list_pages() question

  • adeking

    (@adeking)


    Hi,

    I am trying to hack at an existing theme and have become stuck.

    My blog has a horizontal top bar which is my main navigation. I have set the “depth” to 1 on this so that any sub-pages (or child pages as it were) do not display. In other words, only the parent pages of my blog appear in this top navigation.

    When a user clicks on a specific parent page. I want all the child pages for that parent to appear in a vertical sidebar.

    Can anyone let me know how I might do about doing this?

    Thanks – the site is http://www.macmillan-academy.org.uk/staff_blogs/mrking

Viewing 15 replies - 1 through 15 (of 16 total)
  • MichaelH

    (@michaelh)

    adeking

    (@adeking)

    Hi,

    Sorry, but I am not looking for a collapsable menu. I need to display ONLY the second tier of pages for a specific parent.

    Thanks for your reply.

    Adrian

    Alex Cragg

    (@epicalex)

    not entirely sure of the code, but look at conditional tags and querying the title.

    so you get the page title, and output wp_list_page but in the () put to only display child pages of the title you are on.

    Alex Cragg

    (@epicalex)

    maybe something like…
    if(get_the_title($post->post_parent) != the_title(‘ ‘ , ‘ ‘,false)) { echo wp_list_pages(‘depth=-1’); }

    its a bit of a guess though, and probably wrong, but hopefully a pointer.

    adeking

    (@adeking)

    Hi,

    Yea, cheers this is what I am after. I too hada similar idea, but didnt know how to implement. I will see what I get with that.

    Any other suggestions most welcome….

    Alex Cragg

    (@epicalex)

    maybe the child_of parameter might help…

    adeking

    (@adeking)

    Hi,

    Thanks for all your help epicalex but I am useless at PHP code – just a beginner really.

    I have been playing around with the code you sent, but I am not getting it to display the correct level of navigation.

    If annyone else would like to suggest a tutorial – or a piece of code that works then I will be over the moon!!!

    thanks

    Adrian

    sadish

    (@sadish)

    Most of my themes have this functionality built in.
    download for example my mistylook theme at http:://wpthemes.info/misty-look/version-3/ and take a look at the page.php file.

    Thats what you need.

    Sadish

    adeking

    (@adeking)

    Hi Sadish,

    Thanks very much for your reply. I have downloaded your excellent theme and am looking through it now.

    I cant find anything that looks like it could help on page.php, do I need to look through page-links.php? Or possibly sidebar.php?

    Is the functionality you are talking about on your theme options page? And if it is – does that mean it cannot be easily transfered to my theme?

    Thanks – and sorry for all the questions.

    Adrian

    sadish

    (@sadish)

    It must be in page.php and perhaps you missed it.

    lets do this.
    open up your theme’s page.php and put this code http://pastebin.ca/491582 in it just below the call to the_content().

    See if it works.

    Sadish

    Karita

    (@karita)

    I wanted to do almost the same thing with my website. I have only parent pages on the navigation tab, and also on the sidebar! Once you click on a page, it shows all the sub pages (offered by the mistylook theme, thanks Sadish!)
    What I used for my side bar was this:

      <?php
      wp_list_pages(‘exclude=1, 2, 3’ ); ?>

    With 1, 2 and 3 being the Page_ID of the pages you don’t want displayed on the sidebar.

    adeking

    (@adeking)

    Hi Sadish

    IT works!!!!!

    Love you!!!!!

    sadish

    (@sadish)

    Thanks Karita / adeking 🙂

    Its a pleasure !

    Sadish

    Alex Cragg

    (@epicalex)

    sadish, i was wondering how this can work in a sidebar, im assuming it has to be called within the loop as it is? or am i just not getting it at all? ive got it working in index.php after have posts etc, but in the sidebar it produces nothing. thanks

    sadish

    (@sadish)

    epicalex,
    since this thread is marked as “resolved”, you should post it in a new thread.

    but i have tested this code by putting it in the sidebar.php as well and is working in sidebar. paste it somewhere near the top of the sidebar.php before the call to the widgets.

    Sadish

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘wp_list_pages() question’ is closed to new replies.