WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_list_pages depth (6 posts)

  1. cwapshere
    Member
    Posted 6 years ago #

    I don't want child pages to appear in my sidebar. I've triend various permutations with the depth argumument, but nothing I do seems to make any difference.

    I edited sidebar.php and modified the wplist_pages line as follows:

    <?php wp_list_pages('depth=1&title_li=<h2>' . __('Pages') . '</h2>'); ?>

    The child pages are still listed in the sidebar. What am I doing wrong?

    Thanks,
    Carol

  2. MichaelH
    Member
    Posted 6 years ago #

    That code looks good for the depth, so maybe you are using Widgets?

  3. cwapshere
    Member
    Posted 6 years ago #

    Ah, ok, yes I guess I am. Any hints on what I need to do in that case?

    Thanks,
    Carol

  4. MichaelH
    Member
    Posted 6 years ago #

    Since you are using Widgets then the widget display is likely taking precedence over our sidebar displays. Either put your code outside the widget test in your sidebar.php or better yet, consider downloading and installing Otto's execphp widget. Then put your wp_list_pages code in that widget.

    Please remember to support our plugin authors by clicking on the Donate button there.

  5. Kenv
    Member
    Posted 6 years ago #

    Your Q&A's helped me greatly even though I am not using the widgets for these pages.

    I was wanting to use the "Parent Child" to organize my wifes recipes on her blog. Following the instructions I created a templete page succesuffly.

    The wp_list_pages actually gave me more than I wanted, I just need to go one level deep. The instructions referred to changing the depth and I was trying to figure out how to use the "depth" in the argument

    <?php wp_list_pages('arguments'); ?>

    Your example above enabled me to get my pages to work how I wanted.

    <ul><?php wp_list_pages('depth=1&title_li=&child_of='.$post->ID.''); ?></ul>

    It is now working just how I wanted. Thank you

    Ken
    http://foodblog.jkvetter.com

  6. Steneub
    Member
    Posted 5 years ago #

    EDIT: I wish I could read! The previous poster had the exact problem and solution. Oh well.

    Using Otto's widget also worked for me, but I wasn't done. My widgets below the Otto block were all displaying as list items justified all strangely.

    In order to fix it, I had to wrap the wp_list_pages code with un-numbered lists:

    <?php
    
    echo '<ul>';
    wp_list_pages('depth=1&title_li=&nbsp;');
    echo '</ul>';
    
    ?>

    I hope this helps someone else out there who's had a similar problem.

Topic Closed

This topic has been closed to new replies.

About this Topic