Return to Snippet

Revision: 16837
at August 17, 2009 17:49 by cyberhobo


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

Initial URL
http://codex.wordpress.org/Template_Tags/wp_list_pages#List_subpages_even_if_on_a_subpage

Initial Description
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.

Initial Title
WordPress: Get the root page ID

Initial Tags
wordpress

Initial Language
PHP