Return to Snippet

Revision: 56596
at April 4, 2012 00:06 by rliverman


Initial Code
function get_top_ancestor($id){
$current = get_post($id);
if(!$current->post_parent){
return $current->ID;
} else {
return get_top_ancestor($current->post_parent);
}
}

Initial URL
http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44

Initial Description
From 'Andy' in the comments.

Initial Title
Get Top Parent or Grandparent ID Wordpress

Initial Tags
php, wordpress

Initial Language
PHP