By default WP_Query()
will query posts (unless tax_query
is set). You can change this by setting the post_type
key in your $args
array.
To search for the same post type as is being currently viewed you can do the following:
$args=array(
'post_type' => get_post_type(), //gets the post type of the current 'post'
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page' => 4, // Number of related posts to display.
'caller_get_posts' => 1
);
Related Posts:
- Get list of all registered post types slugs
- single-{post_type}.php not working
- How to disable the single view for a custom post type?
- Custom post type single-{custom}.php not working
- What is singular.php?
- Conditional for single-{post-type}.php
- Custom post type pagination 404 fix?
- Per Post Type Revision Numbers
- WP_Query ignores post_type in category view
- How to get only posts, pages and custom post types in WordPress
- Pre get posts for single post
- Pull Two Posts Into Custom Post Type `single-cpt.php`
- is_singular() not working if called via callback function of admin-ajax.php
- custom post types don’t appear in RSS
- Using previous_post_link and next_post_link to wrap around post sequence
- How do I create new content pages for my Custom Post Type?
- Post Rank on Single Post page based on custom field
- Displaying Meta Box Image
- Custom template for post type not working
- How to retrieve a custom post’s capability?
- Use get_post_types to query only custom posts types
- How to call custom single post?
- Custom post template for particular posts
- Remove single page for custom post type
- Single Template that can be applied only via URL
- custom post type parsed as attachment
- How to store multiple values in 1 meta_key with radio input?
- How do I set default meta value by post type?
- Display a CPT based on a metabox selection
- Incorrect post_type in url of taxonomy term
- Programmatically rewriting slug through functions.php but returns 404
- Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
- How to define which register_post_status goes to which register_post_type?
- Limit the post for differents custom post type in the same wp_query
- Is it possible to filter the display name for post formats for display in the Formats meta box?
- Get term name without a foreach loop
- Cant get paginations on single.php to work with my custom post types
- How to Set Taxonomy Object Description?
- Show only public custom posts in home page
- Including all post id’s of a custom post type into an array
- Custom Post Types — $args vs. labels array
- Add first letter of titles to array, then compare arrays
- post_parent in custom post type
- List of users that clicked a ‘Join’ button at single post
- Inserting custom fields into single.php
- get_post_types – exclude multiple post types by name
- Check if user has comment on current post
- Custom post type and standard post not displaying or working
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- How to show custom field on specific custom post type posts only when filled
- How do I disply an array inside a custom post type?
- adding custom post type “name” to single template
- Custom post type in theme not appearing
- How to copy a custom field from the user’s CPT to the user’s normal posts
- trying to show single post but displays all post on a custom post type
- Add filter to Admin list for all custom post types by their custom taxonomies
- How can I loop at a Specific Taxonomy from a custom post type?
- Update value inside array update_post_meta
- Custom archive page for custom taxonomy and pagination issue
- How to hide list from custom post type
- Loop all post on single.php
- Get an array of the number of post per year of a custom post type (WordPress)
- Custom Post Type Single Page is not working
- How can I write slugs / permalinks as: custom post type -> custom taxonomy and custom post type -> custom taxonomy (one CPT and many taxo)?
- custom post type single page not found after aotumatic publish By the author’s robot
- get_the_terms child terms for current post/custom post only
- Staggering featured post using ‘sticky’
- custom post type single page
- custom post type single post preview for pending status
- Change Custom Post Type to Post + Category
- How can i order my posts by post type?
- Permanent Custom Post Type
- How to show data content from single page which is from custom post type?
- Post types showing tables…Can I do that?
- custom post permalink
- How to get adjacent_post custom_field value
- Single Page of Custom Post Type Not Showing the Content Of post
- DIVs not showing correctly on CPT?
- Display Taxonomy Term for CPT on single-CPT.php
- How to Fix Custom WordPress Loop with Pagination on Single Post View?
- Updated from 3.8 to 4.2 and all post types changed to “post”
- WordPress custom field images not getting inserted into array
- Custom post type single display is ommited
- Meta-Box to add multiple items one at a time and on publish save all
- Single page problem when permalink type changed
- Single Page for two custom post types
- Query child posts on parents single.php?
- Custom Post Type Author Array Problem
- How would I get a list of posts from a custom post type
- Display custom posts in checkbox list
- How to make a list of posts displaying them 5 by 5 with a “next posts” link?
- 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)?
- is_singular won’t call my functions?
- How to add post type in masonry posts elementory widget
- Can I have a specific template for products even if they are standard posts and not CPT?
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- Display custom post type attached media file sizes
- Custom post type REST api 404: Updating failed. No route was found matching the URL and request method
- WordPress Multisite Network Shared Custom Post from Main Site using single-CPT.php
- post__in select all custom posts and not the selected array of ids