Convincing the child to not show up (8 posts)

  1. zero1zero
    Posted 10 years ago #

    I have the Pages showing on the side of the blog very nicely but for some reason, I can't find any reference on how to have none of the child pages hang around there.

    I know that the exclude code can be done but what I want to have is a blanket exclude on all child pages. The landing page for each main page has or will have a number of shild pages that will grow and I'd rather not have to edit the code everytime I add a page. Any suggestions or links to answers?


  2. moshu
    Posted 10 years ago #

    See the "depth" parameter in the Codex:
    (set to 1)

  3. MichaelH
    Posted 10 years ago #

    How about the Template Tag wp_list_pages() with the depth parameter:


    Welcome to the WordPress Support Forums!

    Please help keep the Forums successful by reading:
    Using the Support Forums

    Also, remember the WordPress Codex and the FAQ pages.

    And, thank you, for letting us know if this information proves useful (or not)!

  4. zero1zero
    Posted 10 years ago #

    *smacks self on forehead*
    Thanks to both of you for that. Makes sense now that I look at it.

  5. zero1zero
    Posted 10 years ago #

    Ok, I have run into another bit of a problem. Here is the code that was used in the Template:
    '<?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>' ); ?>

    <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
    <?php get_links_list(); ?>'
    If I place the depth tag in the wp_list_pages tag, it shows up as text on the page. If it is placed in the get_links_list tag, nothing happens.

  6. moshu
    Posted 10 years ago #

    1. You don't put the "depth" parameter in the get_links_list template tag - it doesn't belong there. When the Codex is back, you can study ALL the template tags, they have their own parameters listed on their pages.

    2. Did you read the description, examples etc. at the Codex page we linked to? It gives you several examples how to include multiple parameters. E.g.
    '<?php wp_list_pages('exclude=2,45,728&depth=1&title_li=<h2>' . __('Pages') . '</h2>' ); ?>

  7. zero1zero
    Posted 10 years ago #

    Yes, well, getting to the Codex seems to be a problem so I have not read the entry on it at this point. Anyway, thank you for taking the time to respond.

  8. mores
    Posted 10 years ago #

    well, zero1zero, i think you want the same thing as me :)
    after a long and hard road through this forum, i finally got it :)

    i just added this to my page template:

    <?php wp_list_pages("child_of=$page_id&title_li="); ?>

    this will show a list of children to the current page.
    strange enough, i don't need to check if i'm on a parent page or not, because if there are no children, there will be no list :)
    this is cool!
    now all i need to do is fiddle a bit with the formatting and i'm done, i think.

Topic Closed

This topic has been closed to new replies.

About this Topic