Advertisement
elysium_od

List of child pages with title of parent page Wordpress

May 5th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1.                     <!--TITLE OF PARENT PAGE-->
  2.                         <?php
  3.                         echo empty($post->post_parent) ? get_the_title($post->ID) : get_the_title($post->post_parent);
  4.                         ?>
  5.                     <!--LIST OF CHILD PAGES-->
  6.                         <?php
  7.                         if ($post->post_parent)
  8.                             $children = wp_list_pages("title_li=&child_of=" . $post->post_parent . "&echo=0");
  9.                         else
  10.                             $children = wp_list_pages("title_li=&child_of=" . $post->ID . "&echo=0");
  11.                         if ($children) {
  12.                             ?>
  13.                             <ul>
  14.                                 <?php echo $children; ?>
  15.                             </ul>
  16.                         <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement