I want to display the child pages of the current page you are on.

<?php wp_list_pages('child_of=67&sort_column=menu_order&title_li=') ?>

If I give the id number like above it works perfectly like this:

works perfectly

However I want to use this as a template for multiple pages, but when I use the ID or get Id or echoing the ID, it also take the sibling pages of the parent page. Which I don't need.

<?php wp_list_pages('child_of=the_ID()&sort_column=menu_order&title_li=') ?>

Gets the siblings of the parent pages as well

I can't figure it out what I am doing wrong.

1 Answer 1

$current_page_id = get_the_ID();
wp_list_pages("child_of={$current_page_id}&sort_column=menu_order&title_li="); ?>

Please check the above code

  • Works perfectly! Thank you! Commented Jul 13, 2021 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.