WordPress.org

Ready to get started?Download WordPress

Forums

check for subpages? (2 posts)

  1. thisismyurl
    Member
    Posted 6 years ago #

    I've added a subpage listing to my template and I want to add a header before the listing but only when there are subpages. Right now, my header appears all the time like this:

    <h2>See Also</h2>
    wp_list_pages('title_li=&depth=3&child_of='.$post->ID );

    There must be a piece of code to test if there are subpages or count subpages, any ideas?

  2. Jeremy Clark
    Moderator
    Posted 6 years ago #

    Why not use the builtin heading feature

    wp_list_pages('title_li=<h2>See Also</h2>&depth=3&child_of='.$post->ID );

    Resource:
    http://codex.wordpress.org/wp_list_pages#Hiding_or_Changing_the_List_Heading

Topic Closed

This topic has been closed to new replies.

About this Topic