$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
- How to properly use Categories with Custom Post Types
- Custom post type title of each author in his own post
- how to redirect to a custom post template
- Custom post type tags not showing in search
- How to controll the Posts post type and general wondering about WP data structure
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- HM CMB: Post Select Field for CPT ID
- Post/Custom Post Type URL Access
- Query Custom Post by taxonomy multiple categories
- Custom Post type registering as page post type
- Custom Posts and Posts – next_post_link and previous_post_link not working together
- Display author box on just certain category posts?
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Enable comments for post when comments meta box removed
- Display Posts Query with IF function
- Am I mixing up the concept of posts pages and categories?
- How to setup different permlalinks for posts and pages?
- Display custom post counts for author , not default posts
- Query custom posts from custom taxonomy
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- All in one calendar custom post type query doesnt work as expected
- Building a Data Intensive Website with WordPress
- Query custom posts of logged in user only
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Get posts from current category?
- Query Custom Post Type based on text input
- Display a random customposttype2 excerpt in single-custompostype1.php that shares same taxonomy
- Custom post type filter is being applied to all of my posts
- Does “Custom Post Type” can have page hierarhy option?
- How to: Add a publish immediately button when editing custom WordPress posts?
- Getting custom post type info using get_adjacent_post
- Front-end Image Upload to Custom Meta Box
- Getting the list of the latests posts and custom type posts in the homepage
- How set template for “custom post type” individual post
- If/Else child list for Custom Post Type single template within loop?
- Custom Post Type Query W/Category Dropdown
- Changing WordPress sort order for returned child pages
- Create a custom post type based on ‘Post’
- Query all posts under one taxonomy? Why is my code not working?
- Order posts by years
- Add custom post type to query