/ Published in: PHP

From 'Andy' in the comments.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function get_top_ancestor($id){ $current = get_post($id); if(!$current->post_parent){ return $current->ID; } else { return get_top_ancestor($current->post_parent); } }
URL: http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44
Comments
