Get the root page ID

Get the ID of the root (oldest ancestor, parent without parents) page relative to the current page in a WordPress page template.
Can be helpful for use with wp_list_pages() to create navigation markup.

<?php $root_page_id = ( empty( $post->ancestors ) ) ? $post->ID : end( $post->ancestors ); ?>


There are no revisions for this post.

Tags: , , ,

No comments yet.

Leave a Reply