get page or parent page id


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1.  
  2. #### Submeny, användare WordPress wp_nav_menu Filter
  3. function get_page_or_parent_page_id(){
  4. global $post;
  5.  
  6. if($post->post_parent)
  7. return $post->post_parent;
  8. else
  9. return $post->ID;
  10. }
  11. function has_subpages(){
  12. return strlen(wp_list_pages(array("child_of"=>get_page_or_parent_page_id(), "echo" => false))) > 0;
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.