any
should retrieve any type:
$args = array(
'p' => 42, // ID of a page, post, or custom type
'post_type' => 'any'
);
$my_posts = new WP_Query($args);
Note the description of any
in the documentation:
‘any’ – retrieves any type except revisions and types with ‘exclude_from_search’ set to true.
For more information, have a look at the documentation of WP_Query.
Related Posts:
- Page template query with WP_Query
- get_queried_object() returns null on post date archive
- How to clear the cache?
- How-to exclude terms from the main query the most performant way?
- Pagination with WP_Query is buggy – working for some pages, but not the others
- Exclude comments from a WP_Query object?
- Get the number of posts from the current page results
- Get WooCommerce best selling products for the current month [closed]
- How to count post meta key values for all posts in database
- Custom search form with empty parameters
- Post queries by latitude and longitude
- How to disable the editing of the time and date published?
- Injecting content with $wp_query->current_post restarts from zero on paged pages. How to inject content after X posts, regardless of pagination?
- Find all product that contain terms with %keywords% in WP_Query
- Front End Sorting Questions
- Filtering WP_Query result by category
- posts order by title second word
- Merged two WP_Queries, posts per page and pagination not working
- Why WP_Query::is_date() returns false when ‘date_query’ argument is set?
- Meta_query with or without value
- How can I query posts from multiple roles?
- Query all posts in a given taxonomy
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Using $paged redirects /page/2 to page 1
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- How do I change database charset when using `wpdb`
- get_posts – get all posts by array of author
- Query “Category A” + 1 post from “Category B” – how?
- Unexpected end of file
- WP_Query To call data from diffrent tables
- new WP_Query with author argument return no results
- How to combine two or more WP_Query?
- Assigning a meta_query value based on regexp to wp_query fails
- Clean up WordPress code that repeats
- WP_Query custom query showing only 10 posts on all pages
- Display Featured Post by Categories and Avoid duplicated posts
- How to show optimized list of posts with all their attachment images
- Posts not showing per category after WP_Query?
- wp_query exclude word and category
- How do I exclude the lowest level terms in a taxonomy?
- How can I query users by custom role?
- Pagination inside of a edit page
- Problem with is_tax in WP_Query loop
- Removing duplicate values between two wordpress queries
- Ordering posts by an array
- WP_Query and is_page_template() conditional
- Exclude recently updated post from custom WP_Query using multiple loops
- get_posts output always same post
- WordPress Custom Search Form Displaying Unexpected Results
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Limit number of posts in loop
- How do I get Woocommerce product variation name and variation description in a WP_Query?
- Slow Query On Search
- Loop posts based on permalink term
- Does putting queries within loops cause an issue on WordPress?
- How to get current page nearest parent id?
- How to create Page templates for showing Blog posts in different layouts?
- wp Query Posts to display in Nivo Slider
- How to get only ONE category of “Portfolio” posts to display on main page rather than ALL categories?
- Determining what post is displayed out of total posts found
- Strange behaviour of hierarchical taxonomy archive
- Is it normal that get_post() gets run 300 times and the content of those posts aren’t visible?
- WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- How to get meta key list efficiently?
- Get posts having meta value between two numbers
- WP_Query how to add a thumbnail to the first post from the last 5 posts?
- How order by works?
- taxquery taxonomy get terms
- Separate by Category Post Type
- Using modified ‘meta_key’ to set ‘orderby’ in WP_Query?
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- Query posts in current category but not attachment format
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- Using orderby with 2 meta keys
- wp_query – Modify $query to include duplicate content
- Optimising specific Query with ACF meta objects
- Slow getting posts from category
- Query specific number of posts for each post type in specific order
- Avoiding page loop
- Query Users by post count, last 30 days and display each users post count according to post type
- how do I exclude child categories from a wp_query?
- How to create a loop inside WP_Query?
- how to show only catergory titles on a page in wordpress
- how to fetch post_name from WP_Query using Group by a custom value field
- How to display only top posts of parent categories in loop via WP_Query?
- Empty query on Custom Post Type, using WP_Query or get_posts
- Memory size exhausted when extending WP_Query
- A Depth Like Parameter For “get_posts”
- Search query alteration not working for meta values
- Give attachments an archive page, and exclude unattached ones
- The permalink redirecting to current article on single.php page
- Variations as Single Products [closed]
- Bulk delete comments, foreach loop
- Send a variable with a URL and get a variable with Wp query
- Showing Counts on Comment List with Custom Query
- on attachment.php, how to display previous and next attachment links that follow the same order as a custom WP Query
- loop hierarchical custom post type, child pages only
- I’m trying to get posts under a custom taxonomy but I don’t know what I’m doing wrong here
- WP_query shortcode inside acf Repeater breaks the repeater loop