For any (grand-)child page, I need to get the top level ancestor page title. Can I do that with get_pages? How?
Many thanks!
For any (grand-)child page, I need to get the top level ancestor page title. Can I do that with get_pages? How?
Many thanks!
I've been searching for this as well, get_post_ancestor is as close as I've come, but can't figure out how to get the single top level ID / page vs. the array...
top level page ancestor ID:
<?php echo array_pop(get_post_ancestors($post->ID)); ?>
top level ancestor page title:
<?php echo get_page(array_pop(get_post_ancestors($post->ID)))->post_title; ?>
This topic has been closed to new replies.