Advertisement
Guest User

Untitled

a guest
Jun 21st, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. if(!function_exists('get_post_top_ancestor_id')){
  2. /**
  3. * Gets the id of the topmost ancestor of the current page. Returns the current
  4. * page's id if there is no parent.
  5. *
  6. * @uses object $post
  7. * @return int
  8. */
  9. function get_post_top_ancestor_id(){
  10. global $post;
  11.  
  12. if($post->post_parent){
  13. $ancestors = array_reverse(get_post_ancestors($post->ID));
  14. return $ancestors[0];
  15. }
  16.  
  17. return $post->ID;
  18. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement