$latest_cpt = get_posts("post_type=yourcpt&numberposts=1");
echo $latest_cpt[0]->ID
The only cheaper way than above, I can think of, would be to write your own SQL query to just return the one post and only the column ID.
Related Posts:
- How to get post content by calling ajax?
- Quickest way to get last or oldest post date – WP Query
- Query Posts From Multiple Post Types
- How to show all posts of the category in wordpress?
- Limit the post for differents custom post type in the same wp_query
- Retrieving 3 latest post from each of 5 different custom post types
- How to hook get_terms() to only show count of posts that have custom meta
- Loading post content in FancyBox
- Query post types with multiple keys
- ascending order custom post type
- How to get only one category of custom post type?
- Get all posts WHERE custom_field is LIKE value
- Show Two custom Post type and their posts on category page
- Combine query_posts() and get_posts() into single query
- WordPress Orderby Numeric Value Not Working
- Shortcode for display posts on home page show only one post
- Display only one post each WEEK
- List children on child post
- Get latest 3 posts from multiple CPT in one query
- Meta query for custom post type ignored in main query
- Prioritize posts in query by meta keys?
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Limit the post for differents custom post type in the same wp_query
- Different Ways to Query Custom Post Types?
- Reworking function for counting custom post type posts count
- Number of posts in the archive
- Custom query for custom post_type
- How to Make infinite loop of post
- How to give classname to post if post has no content?
- List all posts in taxonomy term
- 4 posts per page from single category
- Custom Post type showing up in loop, regular posts are not showing up
- Get_post_custom not fetching value from array wordpress
- Create a post automatically if search result has zero results
- Limiting the Number of User Posts to Their Own Posts
- Modify default Related Posts Code to Custom Post Type
- minimize wp_query call to database
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- post type => ‘any’ not applied my custom queries
- Use WP pagination functions on a custom page template
- update a posts of other custom post type
- Get post from Category by Priority
- How to set class to “current-page” on the currently viewed single post within a CPT
- Help ordering custom query by Title, Ascending
- Popup panel is only displaying 1 entry ignoring all others
- How to get Last post Id of custom post type in wordpress
- How to create content automatically when a post is published?
- query_post causes the posts to be loaded twice on load more posts
- Query Only Show Text on Posts With Certain Taxonomy Tag
- Custom Post Type children and grand-children in one list
- WP Build-In Post selector for CPT
- Post content stays the same but permalink changes ?
- How do I display the index position of a post from a custom post type?
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- How do I correctly query posts from a post ID?
- Display posts from another page on home page in wp-editor
- show custom post’s post in two different divs [duplicate]
- How to get permalink of post based on post name?
- How can I show a field ID in Elementor with Request Parameter
- Remove slug from custom post type post URLs
- How to use a custom post type as front page?
- Create Post tabs in single-{content-type}.php with Custom Field values
- Query by 2 values of a repeater ACF field
- Missing the first 6 Posts and displaying posts that are after the latest 6
- pre get posts changing the query
- Adding Custom Taxonomy to WordPress default Post type
- Post type hierarchy
- Custom Post Type order by modified date and custom meta field issue
- Sort by custom field is not working
- Display custom post type from dynamic custom field
- How do I do this with WordPress? Taxonomies?
- Page template with different page and post content
- Display Ad on Specific Categories
- Stuck in Order by more then one
- Changing default ‘posts’ parameters with register_post_type_args
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- BBPress Search results in WordPress search
- pagination not working for category.php (custom post types in categories)
- Different Limit number of post on different archive page
- How to change “post_class()” for a custom post type?
- Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
- Count custom post type based on two meta data
- Dynamic pages for linked categories and content
- Separate Content from gallery (custom post type)
- How to set the mainpage of a custom post type?
- Query Custom Post by taxonomy multiple categories
- Does “Custom Post Type” can have page hierarhy option?
- How to mass get post editor URLs
- Show 5 posts and than 3 posts offset with pagination
- Imported Content Doesnt Show Up On Frontend
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Filter RSS feed for custom post type to events for next 7 days only
- Custom Post Type used for FAQs Accordion
- Pagination not working with custom loop
- Can I set a CPT title field to a dropdown with preset options if user is of a given type?
- Trying to set up a range filter for related custom post types
- Assign a tag to custom post type using a query
- Create a hierarchical list of posts that’s grouped and nested by category
- Two pagination in one page without AJAX
- post__in select all custom posts and not the selected array of ids