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

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

Initial Language