List Child Pages of Parents
-
Hi All
I am using a plugin called Page-list. I use the plugin to list sub-pages of certain pages and sub-pages of the child-pages of other pages. So for the book of Leviticus I have the main page:
https://gucu.me.uk/the-bible/the-old-testament/leviticus/
At the bottom of this page I use the short-code
subpages sort_column=”menu_order, post_date” class=”page-list-cols-3″
This produces the list at the bottom of that page.If you then click on Leviticus 1, I then use this short-code
pagelist sort_column=”menu_order, post_date” child_of=”512126″ class=”page-list-cols-3″
to reproduce the same list as the page above.However, there are over 1000 chapters in the Bible so I will have to reproduce this code on every page. Is it possible to create if statements to reproduce the same effect in a page template please?
I found this code doing a web search but it produces errors.
function Index_child_pages() { global $post; if ( is_page() && $post->post_parent ) $childpages = wp_list_pages( ‘sort_column=menu_order&title_li=&child_of=’ . $post->post_parent . ‘&echo=0’ ); else $childpages = wp_list_pages( ‘sort_column=menu_order&title_li=&child_of=’ . $post->ID . ‘&echo=0’ ); if ( $childpages ) { $string = ‘ ‘ . $childpages . ‘ ‘; } return $string; } add_shortcode(‘index_childpages’, ‘Index_child_pages’);
Any ideas please?
Thanks
Rich
The page I need help with: [log in to see the link]
- The topic ‘List Child Pages of Parents’ is closed to new replies.