Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!function_exists('get_post_top_ancestor_id')){
- /**
- * Gets the id of the topmost ancestor of the current page. Returns the current
- * page's id if there is no parent.
- *
- * @uses object $post
- * @return int
- */
- function get_post_top_ancestor_id(){
- global $post;
- if($post->post_parent){
- $ancestors = array_reverse(get_post_ancestors($post->ID));
- return $ancestors[0];
- }
- return $post->ID;
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement