/**
* Return whether the current page is a child of $id
*
* Note: this function must be run after the `wp` hook.
* Otherwise, the WP_Post object is not set up, and
* is_page() will return false.
*
* @param int $id The post ID of the parent page
* @return bool Whether the current page is a child page of $id
*/
function is_child_of( $id ) {
return ( is_page() && $id === get_post()->post_parent );
}
Related Posts:
- Get first level children of a page ID
- A check for if is parent page, if has children, if has grandchildren
- Prev/Next child navigation for current page?
- Delete Child Posts
- Only allow new subpages to be created
- how to properly list child pages in sidebar?
- Get custom field value from Grandparent Page for Parent and Child Pages
- List the 5 most recent child pages
- Given the page id, check if it has children
- Multiple Conditions for Child Page Title
- How to get a list of all recently published child pages?
- Set order of returned items in the WP_Query() class/function
- WordPress get the child pages of current page
- Show siblings (if any) and parents
- List child pages of current page but limit to specific year
- Child page excerpt
- Display Child Pages of Custom Post Type Parent Page
- Create WordPress child page from page actions
- How to show child page without providing ID so it’s dynamic
- Drop-Down Menu of Current Child Pages
- List of child custom post types lists all custom post types
- Get WordPress Child Page IDs
- Displaying the first child page of the parent page
- Keep page hierarchy in wp_list_pages, even if on a child or grandchild
- Adding title and description to subpage’s featured image
- Show list of Child Post in Parent Post
- List subpages in order
- How to use wp_list_pages on a grandparent page
- parent page grabbing wrong url for child pages – get_page_uri($pageChild)
- i want to get the parent id, only on parent -> child -> child page
- Search anything from a Child and Sub-Pages of their Parent page
- Only one parent page showing
- Child and Parent Pages list of sub pages
- Create a list of pages excluding children of selected page
- WordPress Betheme: Unkown subheader image of a child page
- How to disable alphabetical sorting page
- Structure for calling child pages
- Child pages and sub-pages do not appear. Why?
- Add link to parent page in list of child pages
- Display child pages full template including the content
- Displaying Child Page’s Information
- List child pages, exclude the current page
- Listing Child Pages in Random order
- How to display child pages with in a limited child content?
- Display Tags of Child Pages
- Get post_meta of children and compare to current page ID
- Display the latest content from subpages of another page
- Limit the number of child page displaying
- Show the grandmother/father of the childpage
- How to Hard Set the Parent Page in Template
- How can I structure my pseudo footer nav code with wordpress codex code?
- Website parent child relationship
- Create a “Dummy” parent page for a hierarchy in page listing?
- Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error
- Show content if parent page has children
- Display posts of custom type in hierarchical order
- Show children of top level category only
- Query in a Hierarchical Custom Post Type for Children vs Siblings
- Custom post type hierarchical permalinks not behaving as expected for parent/child pages
- Add theme templates for child categories into the template hierarchy
- Can I make WordPress use a custom template for a child page
- meta_key & meta_value not working with get_pages and custom taxonomy
- WordPress pages with hierarchy
- Load child template based on parent
- Create subpage – filter parent pages list
- Need wp_query to return all children and grandchildren
- How to get specified parent page title in my function
- Best way to give site sub-page it’s own domain?
- Verify if the current page has at least one published child
- How to show all possible parents and children of a hierarchical taxonomy term?
- Child theme does not load all style
- Programmatically add existing pages and subpages to Appearance Menu
- Versioned Custom Post Type (Not the same as revisions)
- Custom post Type, child of a Page?
- How do I Turn This Into An if statement?
- Installing plugins and using complex folder structure with child theme in WordPress
- Weird behaviour on Edit Menus screen
- How to list a page tree?
- Exclude parent with child pages from WP_Query
- Child Category Image
- Give Children Unique ID’s
- Query to get child pages of current page and display it in action hook
- Modify available templates (in dropdown)
- Dynamic menu wp_list_pages displaying only current branch including: current page, his siblings and its childs
- Parent Page > Child Page Menu
- Listing all child-pages of a parent-page on the parent-page and each child-page?
- Display a list of sub-pages of Custom Post Type Parent Page
- I have a problem with displaying children pages of custom post type
- Display list of pages that contain a certain string within the slug
- Running get_posts within get_posts to get children of children
- Child Theme problems
- How to show the view more on my display of pages shortcode
- Custom post type child page 404
- Custom Post Type children and grand-children in one list
- How to include child terms within parent?
- WordPress Template works until page becomes a child
- how to display page title only for child category pages
- How to get child pages and add unique class only to active page?
- Differentiate Between Parent & Child Categories
- Slug of a child page is accessible with and without the parent slug in the URL