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?
- Use register_post_type() to modify an existing post type
- Custom post type single page returns 404 error
- 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
- Order by & include array by specific post ids
- Template for specific post of custom post type
- WP_Query ignores post_type in category view
- Single custom post type page redirecting to 404 page
- 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`
- How do I implement custom fields without using any plugins?
- is_singular() not working if called via callback function of admin-ajax.php
- Disable Single Post View for Specific Taxonomy on Custom Post Type
- custom post types don’t appear in RSS
- Limit the post for differents custom post type in the same wp_query
- array_pop() expects array, boolean given for $event_type_term ->slug
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- How to get a list of term names of the custom post type im currently on in single.php
- is_singular won’t call my functions?
- Create sub single pages
- Using previous_post_link and next_post_link to wrap around post sequence
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- How do I create new content pages for my Custom Post Type?
- Registered Post Type Isn’t Showing in Admin Menu
- Display “Post 2 of 4” on single post page?
- posts_nav_link on single post template
- Post Rank on Single Post page based on custom field
- Disable single pages and archives and keep preview
- Save custom post type in different table
- Displaying Meta Box Image
- Custom template for post type not working
- Make custom post type display as a page
- Automatically adding meta data to posts or multiple query help
- Disable single view in register_post_type [duplicate]
- Archive page for custom post type not working
- Redirect Single Post CPT (Custom Post Type) to a specific URL
- Need post_type_archive_title function but in ‘single’
- Multiple post type queries (with specific arguments for each)
- pagination redirecting from page number url before page requested
- How to retrieve a custom post’s capability?
- Use get_post_types to query only custom posts types
- Create a post in custom post type using field in registration form after users submit form
- How to check the terms in single custom post type template
- How to show the archive / post type description on Single templates
- Need to display same custom post type on 2 different singles templates
- Made Custom Post Types, but single.php not working
- Posts of custom post type load the page template
- WP_Query | ‘post_type’ doesn’t work
- How to call custom single post?
- Custom post template for particular posts
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- Save an array from drop-down in custom meta box
- Remove single page for custom post type
- Single Template that can be applied only via URL
- How do I display tags for a custom post type single page?
- child of post type (custom)
- Custom post type not displaying content from single-{custom post type} page
- 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
- Single template showing all posts of that type
- Limit amount of posts made within a custom taxonomy
- Incorrect post_type in url of taxonomy term
- Programmatically rewriting slug through functions.php but returns 404
- Display post content with respect to its title?
- How to display single post from custom post type loop?
- Setup template_redirect using has_term when NO term assigned
- 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
- Not Able To Render Single-CustomPostType.php File
- Single page not working for custom post type
- Is it possible to filter the display name for post formats for display in the Formats meta box?
- get_the_post_thumbnail_url(‘full’) returns empty from custom post type
- 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
- Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
- Add first letter of titles to array, then compare arrays
- Associate page w/ specific single post template?
- Display custom post types in wp_list_pages
- Can I change my post type to anything and my site still work?
- Query Custom Post Types with checkboxes
- post_parent in custom post type
- List of users that clicked a ‘Join’ button at single post
- Create Array from custom post type to display a slider
- Custom filter for main search: how to exclude specific post_type from search results
- Inserting custom fields into single.php
- Inefficient Query Confusion