/**
* 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?
- Get the children of the parent category
- How can I hide children of draft pages using wp_list_pages()?
- Display a list of child posts on parent posts of a custom post type
- 404 on child page when parent page slug is identical to custom post type
- How can I programmatically create “child” pages on theme activation?
- List child pages of a specific page
- Using pagination with get_posts on page type
- Child pages on hierarchical Custom Post Types 404s
- Add class to the items in wp_list_pages
- Displaying child page content of a certain parent
- Get only the grandchildren, not the direct children of page/current page?
- Remove custom post type slug not working for child pages
- Page as a child of a Custom Post Type
- get_posts() excluding all children of a specific post/page
- Pagination of a WP_Query Loop in a child-page page template
- Schedule Page to Menu [duplicate]
- Advanced or not so advanced pre_get_posts query
- Display the contents of a custom field of a page on their child
- How to hide all child pages with post_query?
- How to display all subpages and short by year
- How to populate a parent page with its child subpages and associated templates
- Removing Parent Page URL While Keeping the Navigation Intact
- Organizing Your Pages
- Custom page template for multiple pages
- Display child pages in sidebar of parent page in wordpress
- Showing categories and subcategories with posts
- How to Create a Random List of Child Pages
- How to customize taxonomy archive template files for subterms?
- $pages = get_pages(‘child_of=’.$post->ID); Why arguments are concatenated?
- Orderby menu_order not working; menu is sorted on publish date
- Do we need to change our child function.php to require/include child dir files when we add an over-riding file.php into the child theme
- How to hightlight all ancestor menu items of a child page NOT displayed in menu
- List child categories from parent category on custom taxonomy page
- Don’t repeat posts from children in parent taxonomy query
- Only looping through pages that have children or subpages
- Check for parent category
- How to make a query returning pages from multiple parents
- How to customize ‘children comments’ in WordPress?
- Check if parent page has child page of certain slug
- Child Theme not overwriting Parent theme php file
- Standard Page Child of CPT Not Found (404)
- Creating navigation out of specific IDs and their children?
- How to use wp_dropdown_pages or wp_list_pages to accomplish a menu like this?
- List of child pages fetch next results at link click
- Showing main menu and child menu in diffent places in a same page
- “Static” Child Menu with Accordian
- List CPT by menu_order with children right after parent
- List of pages – AJAX load more
- I have a website issue I am trying to resolve