• Resolved csleh

    (@csleh)


    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?

Viewing 1 replies (of 1 total)
  • Thread Starter csleh

    (@csleh)

    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 } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘end php for a listing’ is closed to new replies.