I’m assuming that you’re asking how to do it with code? (Doing it in backend is pretty easy – just try to edit parent page and see the ID in URL).
So how to check post parent in code? It’s also very easy – direct parent is stored in post_parent
property. If post has no parent, it will be 0
.
So all you have to do is:
global $post;
$direct_parent = $post->post_parent;
Related Posts:
- How does wordpress calculate the page depth?
- Check whether the child page has siblings
- How to echo excerpts with wp_list_pages?
- Extra title output with this function wp_list_pages
- List child pages by slug not ID?
- Combining ‘depth’ with ‘include’ in wp_list_pages()
- Get parent of current page
- Post Fetching Ignoring Sort_Column?
- Exclude pages by menu order
- Change page name in admin list
- Check if the child page has sibling pages, and bookmark current page
- Keep page hierarchy in wp_list_pages, even if on a child or grandchild
- Check if page has subpages
- How should I set up a Tumblr blog at a WordPress Page?
- Translate dashboard metabox
- Include parent page in list of child pages
- wp_list_pages get the hole hierarchy for current page
- Remove and change pages label
- Get All Pages as strings in array
- How To List Sibling Pages And Include The Featured Image?
- How to make in post Parent page children page list nummbered
- Custom wp_list_pages() function
- How to set post slug when using wp_insert_post();?
- Check if is on child-page of a particular page
- Create a page without adding a page in the Database
- What methods to use to create small, editable pieces of text for static pages?
- Hide page visual editor if certain template is selected?
- What is an alternative to get_page_by_title()?
- Get Permalink for the top level parent of child pages
- Get page id by title?
- How to embed page content in a blog post
- Notify admin when page is edited?
- How do I modify this page template to show subpage excerpts (not post excerpts)?
- Dynamically Load Styles and Scripts from Theme Functions.php
- How should I best incorporate WordPress in my static website?
- What are the options for running custom css and javascript files on a page?
- How to build a post and comment editing form in a page?
- Wrong Sub-Page Order
- Can’t change parent page
- can i create 2 blog ‘feeds’ within one blog
- Call the content of a page in AJAX in WordPress
- I made a custom page but WordPress seems to strip any HTML I put in this page
- How to dynamically save a selected option from page “Templates” selectbox?
- Change names of pages in wordpress
- WASM page in WordPress website
- wp_list_pages sort order is different for different languages [closed]
- Include a specific page in your template
- Is it possible to have a landing page based on the visitors location?
- Remove number in URL
- Where is the key _wp_page_template passed?
- Displaying page content in category archive (archive.php)
- Is it possible to skip certain specified pages when using < prev and next > links?
- Custom Page Order instead of Alphabetical
- How to redirect a page to another?
- Missing Page, But Still Exists In Preview
- How to create a page that lists all the experts(Users with same access permission as author)?
- Get the ‘Content Permission’ roles as defined in a page
- Create a page that’s to not be indexed or accessible via slug
- How to control who can view certain pages in BuddyPress? [closed]
- access control for assets in a website powered by wordpress
- How to remove only pages from Admin Bar?
- Query specific Pages
- Phantom page can’t get rid of/can’t get at to change
- ‘x’ Converted to html code in example: 5×10
- Published pages missing
- Getting ACF Field in Page – From the Footer
- How can I send an email when someone uses the HTML download Attribute?
- Later blog post pages give 404 error
- Different css file not working for the page template I created
- How to change the order of the Front Page so it doesn’t appear first
- 404.php only works if I’m logged in. Everybody else redirects to wp-login.php – why?
- Using index.php as page template
- What’s the section of code (or loop) which retrieves the Page title and description?
- How to backup just pages from my site, but not posts with other post_type values
- Template field missing in page attributes
- How to hide a page in wordpress made for menu
- How to change default home link title?
- Recovering a page from the drafts
- Pulling images from the media folder category to display inside a page
- My Password Protected Pages Aren’t Working
- Page view displays not properly after update wordpress
- Display grandchild page content on parent page
- Converting HTML to WordPress theme: integrating pages function and using its text editor, conditional enqueuing
- Display custom_post_type with current taxonmy of a page
- Category Page Custom Layout [closed]
- How to copy specific page content and create child page?
- How to output different content of page on different places in my template
- WordPress slow pages/post, hangs and white text
- Prevent page from displaying
- Previewing Draft shows white page, publishing works fine?
- Changing title bar in browser window of theme “Encounters Lite”
- Custom Filter using meta_value in wordpress admin list not working
- Loading custom jQuery and HTML in a WordPress page
- making a pseudo-static page
- Dynamic content in pages
- Javascript will not run properly
- link a custom page into menu
- Website fully loads then immediately crashes in Internet Explorer [closed]
- How to display a page?
- How can a user login on a wordpress page?