I use this maybe helpfull
<?php
$title = get_the_title($post);
$parent_title = get_the_title($post->post_parent);
echo $title;
echo $parent_title;
?>
<?php
global $post; //wordpress post global object
if($post->post_type == 'page'){
$content .= '<br /> This item is a page and the ID is: '.$post->ID;
} elseif($post->post_type == 'post') {
$content .= '<br /> This item is a post and the ID is: '.$post->ID;
}
echo $content;
?>
Related Posts:
- Page template query with WP_Query
- How to display page content in a page template?
- Does WordPress generate an automatic page for post formats?
- Single page theme that uses pages for the content
- Trying to list out child pages with WP_Query
- Order by menu structure
- Targeting specific pages in the loop
- What are the differences between “Latest Posts” and “Static Page”?
- WP_Query not retrieving by random order under parent
- Set if condition with wp_nav_menu
- Set order of returned items in the WP_Query() class/function
- Search pages that are a child of the current page
- How to display summary content from a Page (Not a Post) on another page
- Serve specific “template” page at any URL that ends in its slug
- Display custom tags on pages that have a specific page parent
- Is there a reason why Pages are not publicly_queryable?
- Why post__not_in is ignored?
- Exclude parent with child pages from WP_Query
- Create a loop on my pages with new “WP_Query”
- All blog data on a page using custom query gives 404 for page 2 and onward
- When listing child pages run out of memory
- WPQuery calling specific posts problem
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- Display specific page (that is child) content on parent page
- Get query results with a page title
- How to get current page nearest parent id?
- How to get main menu only with wp_nav_menu
- Unable to paginate a custom page query
- How to create single page site in WordPress
- Determine if ID is page or post and query the ID
- How to query for a page, get data, then query for child pages of that page
- Get list of all Grandchild Pages
- Custom query does not find pages
- How to get pages of parent (non-recursive)?
- WP Query and multiple pages
- How to use custom page for all posts with custom url, call another directory?
- display the children of the post using the current page as the main parent
- pages shortcode filtering by category
- How to create page that lists tags by initial letter?
- Get a page ancestor from a most viewed list
- How can I use a specific wordpress page template if certain words are used in page title [closed]
- Category Archive not working for pages
- Retrieving category pages from subcategory returns empty sets
- Issue in If else condition [closed]
- Show parent’s child and also child’s, child on a page?
- get contents and permalink from a specified page
- Hierarchical List Pages as a table
- Get next post when using pagination with WP_Query?
- WordPress pagination returns the same posts
- Find out total number of pages in global query on archive page?
- Is it possible to completely stop WP_Query retrieving posts?
- Pagination returns 404 after page 20
- Make a WP Query search match exactly the search term
- Make loop display posts by alphabetical order
- Displaying several specific pages using WP_Query()
- WP_Query by Category Name
- WP-CLI How to generate a list of posts with corresponding meta values
- Query to return maximum of one post per author
- Warning: urlencode() expects parameter 1 to be string, array given
- All sticky posts are returned in custom query
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Can not switch the queried post in pre_get_posts hook
- Why use JSON API to display recent posts?
- Pagination problem after WP_Query with tag filtering
- Get list of terms that have posts in another term
- Get data of all posts of a query before pagination
- Custom query for sidebar isn’t returning results
- How to vary post loop results layout and resume?
- Adding an array from a query string to a WP meta_query
- WordPress add_rewrite_rule() cannot visit lower url levels
- Using Advanced Custom Field for file upload, how do I load the file url
- Retrieve posts using thumbnail id as meta key
- Modify Search Query if original Query gave no results
- How to cache wp_query with pagination using transients?
- Problem with WP_query
- Why is WP_Query not displaying expected data?
- Filter post query to only show direct children of category
- has_excerpt() not working inside wp_query
- Get every post with value in meta key
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- How to get posts by category and by choosing a taxonomy term?
- Paginate pages with dynamic query
- WP_Query loop doen’t work with my custom taxonomy
- Deleting terms from the WordPress wp terms table
- In a WP_Query can I force the results’ is_singular() to be set to false?
- Order (by ASC) posts with meta_key so posts without values are last
- Get posts that match defined arrays of tags
- WordPress live search and filter
- Why can my filter query SOME metadata but not other metadata?
- How can I use WP_Query to sort ‘event’ custom post type by date?
- Show posts from categories instead of tags
- Sorting Posts by Taxonomy thats not within the query’s $args
- Why is $wp_query fetching nothing?
- How to query post into a complex slider
- WP_Query Sorting Posts by month … timeline effect
- My class function is not seeing GET url paramaters
- Adding css tweak based on page template
- How to include custom fields in wordpress search
- Extend search query to search meta keys values based on search string
- AJAX multiple search boxes not merging with array merge