Tag: Root Page ID

  • WordPress Get Root Page ID

    WordPress Get Root Page ID

    this snipet will show you how to get root page id and title in wordpress! global $post; $parent_id = $post->post_parent; $post_id = $post->ID; $ancestors = get_post_ancestors($post_id); $root_id = (!empty($ancestors) ? array_pop($ancestors): $post_id); $child_of = $root_id; $widget_title = get_the_title($root_id);