WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] end php for a listing (2 posts)

  1. csleh
    Member
    Posted 4 years ago #

    I found some code that I think will show a link back to parent page.

    if ($post->post_parent) {
    $parent = get_post($post->post_parent);
    if ($parent->post_parent) {
    $children = wp_list_pages("title_li=&child_of=".$parent->post_parent."&depth=1&echo=0&sort_column=menu_order");
    } else {
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&depth=1&echo=0&sort_column=menu_order");
    }
    } else {
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1&sort_column=menu_order");
    }
    if ($children) echo "
          " . $children . "
    ";

    I tried having <?php at the start and ending with ?><?php } ?> and variations of that but keep breaking the site. How can I end the code so it will display?

  2. csleh
    Member
    Posted 4 years ago #

    this shows a link back to parent page.

    <?php
       if (!empty($post->post_parent)) {
        $parentTitle = get_the_title($post->post_parent);?>
      <a href="<?php echo get_permalink($post->post_parent); ?>" title="<?php echo $parentTitle; ?>">Back to <?php echo $parentTitle; ?></a>
      <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic