$my_query->post_type
refers to the post type of the query (in this case an array), and not the results. (Its recommended to use $my_query->get('post_type')
too, but anyway…).
To get the current post’s (in the loop) post type:
$post_type = get_post_type();
You can also use that function outside the loop by passing the post object / ID. See codex entry.
Related Posts:
- Is it possible to request several post types from a feed?
- What is the meaning of the various post messages?
- wp_list_filter() and supports
- What does get_current_screen() do?
- Post types – Normal Post – Image
- WordPress register_post_type Invalid post type
- How to edit default post settings
- Check If post id exist in custom post type , outside of loop
- Conditional based on post meta
- Querying for multiple post types in SQL
- Displaying only the current category in template page
- How to get all CPT names into WP_Query ‘post_type’ parameter?
- Show post type taxonomy
- wp_dropdown_pages() returns empty string for post type anything other then page
- Use register_post_type() to modify an existing post type
- What are custom_css and customize_changeset used for?
- Are captions stored anywhere?
- WP_Query ignores post_type in category view
- How to get only posts, pages and custom post types in WordPress
- Exclude top-level pages from search results
- How to get attachments for a specific post type?
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Dynamically Set WordPress Post Title To The Category Name
- Twillio How To Send SMS for Custom Post Type
- Custom Post Type causes Page Not Found
- Is It Possible To Have Shared WordPress Custom Post Types?
- Show all parents and children in custom post type in right order
- wp_query for displaying attachments with a tag
- How can I pick a single post from the latest 3?
- How do I search inside specific taxonomies in WordPress
- How to retrieve a custom post’s capability?
- Use get_post_types to query only custom posts types
- WP_Query | ‘post_type’ doesn’t work
- Move value from one meta key to another
- How to restrict wordpress search to pages and disable products listing search?
- Does only custom post type have post type archive pages?
- Search query -> Show all pages except certain template
- child of post type (custom)
- how to fetch the meta field keys/meta boxes from a post type?
- How do I set default meta value by post type?
- Limit amount of posts made within a custom taxonomy
- force permalink slug for page vs post_type slug parent
- get_the_post_thumbnail_url(‘full’) returns empty from custom post type
- Adding in support thumbnail removes editor
- why there are so many posts whoes post_type is revision? will these records waste too much database space?
- wp_list_pages() refuses to output posts
- Post type no single page
- get_post_types – exclude multiple post types by name
- Remove taxonomies using register_post_type_args
- post_type internal ID?
- Setup database structure with books, authors, languages etc. for publishing house [closed]
- How to check if it’s edit.php & post_type is set?
- Pass PHP through redirect and custom fields
- Dynamic pages for linked categories and content
- How to copy a custom field from the user’s CPT to the user’s normal posts
- get_post_types not working properly in admin
- Post types translation
- Replace Post-Title with variable
- Custom wp_query differs on index page and category page
- Add filter to Admin list for all custom post types by their custom taxonomies
- Post Type => Any conundrum
- Sort query output on taxonomy term archive by post type using pre_get_posts
- Pros and Cons of Post Types vs. Multiple Blogs
- query_posts doesnt show pages with given ID when post_type => page
- Filter Media by attached page or blog post in Library
- Target only single product page
- Error in Fetching Custom Post Type parent Category URL (slug)
- How do I make the comment disappear after deleting from the database?
- Custom Post Type Single Page is not working
- WordPress private post won’t display to other admins
- Unique IDs for Post Types and Taxonomies
- Get all post types that supports tags
- How can I get the content of the current page in my loop while merging post-type
- Quick Draft widget (dashboard.php) using custom post_type
- Shortcode is not showing content when placed in editor (post_type = page)
- Distinguish between page and post in function
- custom post type single page not found after aotumatic publish By the author’s robot
- Filter by Post Type
- Custom slugs for Each Tab
- How to create custom post type selection to nav menu
- How to mix 2 kinds of post types
- Change Custom Post Type to Post + Category
- Shortcode in excerpt
- How can i order my posts by post type?
- post_type not working when tag__in is present?
- Permanent Custom Post Type
- How to set a default CPT template and create post attribute´s display rules?
- custom post permalink
- Adding featured image to post display widget
- How to set “manage categories” capabilities on a post type taxonomy but not on the general categories?
- Get_posts not returning any posts when used with switch_to_blog
- How to Display Child Taxonomy Posts
- Custom Filter using meta_value in wordpress admin list not working
- Add a tag like a post
- How would I get a list of posts from a custom post type
- How can I make a custom post type that loops pages in a new dashboard page, each single page is a new dashboard page (all within the back-end)?
- permalink and $_GET
- Problem with permalink structure for WordPress custom post_type archive template
- How to batch convert comments to posts?
- custom taxonomy not return in the code