Just set post_type
to an array of types, and posts_per_page
to 1
and you’ll get the most recent post from those types.
$args = array(
'post_type' => array( 'type_1', 'type_2' ),
'posts_per_page' => 1
);
$latest = new WP_Query( $args );
Related Posts:
- Adding a span when custom post type is updated
- Display children and grandchildren of a custom post type
- WP_Query search posts by custom post type and custom taxonomy
- Conditional to modify query results
- WP_Query is printing out only one post when posts_per_page is set to multiple
- WP Query to displaying date and posts for that date?
- Can’t get order_by meta_value_num to work properly
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Very Slow Page – How to Optimize # of Queries?
- How to make sure content doesn’t display if selection is empty
- creat filter with wp_query
- Configuring a meta query with multiple post types that have the same relationship on a single page
- How can I group posts by months and years?
- Loop increase number
- Using wp_query to modify the loop in index.php for a CPT
- WP_Query Custom Post Type if Category ID Equals
- Is This Code Efficient – Or is there a better way?
- Different options per post type in WP_Query
- Show message when query has no posts
- Undefined $post in wp_query
- Custom post type and custom taxonomy 404 on page 2
- Using Wp_Query, Json to add Highcharts series data
- foreach loop inside the loop creating duplicates in output
- Foreach loop returning more than one item when querying taxonomy
- Page that lists publications by classifying them by taxonomy
- set object terms after some some time of published post – functions.php
- Alike Shortcode using in Custom Shortcode
- Query custom post type that has a serialized relational advanced custom field value
- Sort custom post column by generated value?
- WP_Query – How To Query Only Custom Posts With No Children of Their Own?
- wp_post_delete is deleting all offices
- Tell wordpress to show a single page instead of an archive page
- Search result based on URL
- Custom Taxonomy – fields
- Custom Post By Category
- How to get the posts that my following users are liked?
- CPT post doesnt shows tags and category on backend admin page
- The most recent post of custom taxonomy
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- Loop carousel slider in wordpress
- Values inside a custom field to determine which category posts to display
- WordPress multi-query not returning as expected
- Trying to combine multiple WordPress queries
- Custom Post-type not returning the right child_of
- Pagination not working on homepage
- Query Custom Post Type by Tag
- How to manage wordpress knowledge base/wiki/posts collections
- Store custom post type with JSON content
- Meta query with boolean true/false value
- Search multiple custom fields by using meta_query
- category__in not working on custom post type
- Displaying Posts Related to Other Posts by a Taxonomy Term?
- Ajax filter with custom taxonomies
- Date query for a custom meta field
- Set default option in dropdown of WP_Query?
- Custom post type loops with different page templates
- How can I programmatically save data into custom fields that contain serialized data?
- Row actions not showing? Why?
- Displaying custom post type on front page
- Custom WP_Query not returning results when querying custom post type
- Link users to a custom post type
- Weird problem happening with custom taxonmy when creating/updating posts
- Why get_posts() not returning only selected category posts from Custom Post Type?
- CPT + CMB2: data not displaying for only first post in loop
- Problem querying Custom post type by custom fields
- Using custom field content as expression in IF statement [closed]
- Make a custom_post translatable
- How to update post meta on uploaded image from a custom form?
- can these 3 queries be re-written as 1 query?
- cannot override post_types in WP_Query()
- Wrapping x posts in html without leaving empty html
- Custom filter for main search: how to exclude specific post_type from search results
- Filter content in shortcode
- Shortcode with WP_Query more than once on one page
- Can’t change posts per page in WordPress Post Type Query
- How do I get the index for a custom post?
- Commas not displaying in implode
- add custom tags for custom post type in wordpress
- Shortcode / WP_Query in post changes context
- WP_Query order custom post type with certain meta key value by post modified date
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Display custom-post type based on the Title matching the current selected value
- Is it a connection or relationship between 2 custom post types?
- Custom front-end form for adding post – Category problem
- How to search through all child taxonomies using WP_Query?
- Numeric pagination custom post type
- Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
- WP Query filter search. Result show all posts instead just custom post type
- Display posts of a hierarchical custom post type excluding parent posts
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- How to query posts by meta keys AND under specific category?
- How can I base a query off of the current page post type AND a meta value from another custom post type
- Fallback if statement based on the number filtered from it
- WordPress Set A Static Page/Template For All Sub-Pages
- Add HTML before a specific div?
- How to hide home title on pages and posts?
- Get images only from a certain post type