• Resolved Malin

    (@neostoric)


    I want the parent of the subpage to show up as the heading.
    In this code the id of the parent shows up as the heading. How do I get the parent id title instead of the parent id number?

    wp_list_pages(‘title_li=<h2>’ . __(“$post->post_parent”) . ‘</h2>&child_of=’.$post->post_parent.’);

    I also tried <?php the_title(‘<h2>’, ‘</h2>’); ?> which gives the title… is there a way to make it the “parent-title” instead?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Malin

    (@neostoric)

    Okay, the problem is solved, here’s the code:

    <?php
    if($post->post_parent)
    $children = wp_list_pages(‘title_li=&child_of=’.$post->post_parent.’&echo=0′); else
    $children = wp_list_pages(‘title_li=&child_of=’.$post->ID.’&echo=0′);
    if ($children) { ?>

    <div id=”rightpadbox”>
    <h2>
    <?php
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
    ?>
    </h2>
    `

      <?php echo $children; ?>

    </div>
    <?php } ?>

    I got it from a post by “converting2wp”, check it out here

    Awesome! Thanks so much for posting the code for that!!! It worked beautifully on my site.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Parent Page as heading in wp_list_pages’ is closed to new replies.