Title: end php for a listing
Last modified: August 19, 2016

---

# end php for a listing

 *  Resolved [csleh](https://wordpress.org/support/users/csleh/)
 * (@csleh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/end-php-for-a-listing/)
 * 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](https://wordpress.org/support/users/csleh/)
 * (@csleh)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/end-php-for-a-listing/#post-1110146)
 * 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.

## Tags

 * [close](https://wordpress.org/support/topic-tag/close/)
 * [code](https://wordpress.org/support/topic-tag/code/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [csleh](https://wordpress.org/support/users/csleh/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/end-php-for-a-listing/#post-1110146)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
