Advertisement
isaacadams

Children list

Jun 9th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. /* Function.php */
  2. function wpb_list_child_pages() {
  3.  
  4. global $post;
  5.  
  6. if ( is_page() && $post->post_parent )
  7.  
  8. $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
  9. else
  10. $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
  11.  
  12. if ( $childpages ) {
  13.  
  14. $string = '<ul class="wpb_page_list">' . $childpages . '</ul>';
  15. }
  16.  
  17. return $string;
  18.  
  19. }
  20.  
  21. add_shortcode('wpb_childpages', 'wpb_list_child_pages');
  22.  
  23. /* Style */
  24. ul.wpb_page_list {
  25. list-style: none;
  26. list-style-type: none;
  27. background-color: #eee;
  28. border: 1px solid #CCC;
  29. padding: 20px;
  30. }
  31.  
  32. /* Shortcode */
  33. [wpb_childpages]
  34.  
  35. <?php wpb_list_child_pages(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement