Wordpress - List page children in a list without the link to the current page


/ Published in: PHP
Save to your folder(s)

Must be placed after the_post() so make sure you verify that if you place it in the sidebar.


Copy this code and paste it in your HTML
  1. <?php
  2. $pagelist = get_pages("child_of=".$post->post_parent."&parent=".$post->post_parent."&sort_column=menu_order&sort_order=asc");
  3. if (count($pagelist)>0) { ?>
  4. <h2>Subpages</h2>
  5. <ul>
  6. <?php
  7. foreach ($pagelist as $page) {
  8. if (strlen(get_the_title($page->ID)) > 30 ) $titlu=substr(get_the_title($page->ID), 0, 30).'...';
  9. else $titlu=get_the_title($page->ID);
  10. if ($page->ID != $post->ID)
  11. echo '<li><a href="'.get_permalink($page->ID).'" title="'.get_the_title($page->ID).'">'.$titlu.'</a></li>';
  12. else echo '<li>'.get_the_title($page->ID).'</li>';
  13. print "\n";
  14. }
  15. ?>
  16. </ul>
  17. <?php
  18. }
  19. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.