Try This Code
$latest = new WP_Query( array (
'post_type' =>'your-post-type-name',
'post_status' =>'publish',
'orderby' => 'rand',
'posts_per_page' => 3
));
while ( $latest -> have_posts() ) : $latest -> the_post();
echo the_ID();
endwhile;
Related Posts:
- How to Check if a Page Exists by URL?
- How to allow slashes in single posts when i click in the edit permalink button
- WordPress not opening posts with only numbers if permalink is post_name
- Permalink doesn’t get displayed in Twitter button (Local WordPress problem?)
- Post is blank when I click on the link
- Making posts permalinks consistent numbers
- Can Permalink structure of %postname%/%post_id% improve performance
- Can I show category name in url for only one of my categories?
- Permalink Short code showing unnecessary link text inside the loop
- How can I make a post sub link?
- Does having category name in permalinks affect SEO when having a post in multiple categories?
- How to add a ‘News’ section to specific posts in WordPress
- Prevent Archive URLs
- Category URL to use same string as Post URL Permalink
- Post & Category Archives URL structure
- How to change post template via url?
- Default post type doesn’t display in url
- Blog posts are not appearing as subs of Blog Page
- How to add paraent in Blog post URL in wordpress
- Modify Post URL Programmatically
- Get page ID of page that is set as the posts page
- Where is the old post permalink slug stored?
- Access post from post id in URL
- How to add category to: ‘wp-admin/post-new.php’?
- Use category base slug in posts’ permalink
- Are post ID’s reliable?
- Get current post id in functions.php
- get all posts ID from a category
- Strategy for handling hierarchical pages with empty parent content
- How to automatically generate a unique random slug
- Custom permalink structure only for default posts
- Post slugs and images cannot have same name?
- Change permalinks for post type ‘post’ only
- Get the current post ID as a variable in Javascript
- Is post ID number always incremental n+
- Change the Slug of Post Type post to baseurl/post/%postname%
- Different permalink for posts and authors
- Pretty URL with add_query_var
- Open WordPress ‘Add New Post’ admin page with parameters set via $_GET
- get_permalink returns default link
- Group Posts by First Letter of Title
- How do you get all the urls of images attached to a post?
- Keep getting same permalink with WP_Query?
- How to control which category will be picked for the slug of a post?
- how to get permalink using sql
- Change slug with custom field
- Why can posts never have a number as the link?
- Are all ID’s used unique?
- $post->ID displays wrong ID
- How to get the post id from a permalink?
- Must permalinks always point to single post pages?
- At my posts archive page, outside the loop, get_the_id() returns the top most post’s ID
- Possible to create a permalink to sort with meta_key?
- Post custom permalink results in 404 for archive page
- how to grab first link in post… and of course call it
- Some posts returning 404 instead of displaying post
- Custom post type single (permalink) throws a 404 error
- Link for the page archive for posts, like using custom post types with get_post_type_archive_link
- Showing random content / pictures from earlier posts in a sticky post?
- Post in Multiple Categories to stay in current category (permalink, next previous post link)
- Get the post_id of a new post
- get post id in while loops outputting page id
- How can I extract the URL of a link from a post?
- How can I display a specific user’s first published post?
- Undefined variable post_id in custom quick edit coloumn
- Random post permalink
- What Defines What Category A Post Picks (if in multiple)
- get_permalink executes link without https
- Permalink Settings: optional settings doesn’t apply to editor
- Custom post type permalinks breaking due to 3.1 bug fix
- Create a separate JS application for an individual post?
- How can a guest view the “Pending Review” Post?
- Create pretty permalink for a post knowing the permalink structure
- Changing my permalink structure – will new layout conflict with existing page?
- How to change the page break URL from ../post/2 to …/post/page2/
- Link post permalinks to subdirectory /post
- change default post archive page link
- How is WordPress manipulating the posts like there are folders?
- Getting post id from wp_insert_post_data function?
- Does an article (post) id ever change?
- How to get the post’s parent ID?
- Remove permalink from images when inserting into post
- Can a page_id and a post_id be same?
- Is there a better, more efficient way to get the post id outside the loop?
- Remove the Edit button in posts for permalinks on certain user roles? WP 3.3
- Remove slashes (both before and after) in relative post url
- Getting current post ID in functions.php
- Buddypress activity id
- Dynamically generate child-URLs for posts or custom posts
- Random post category URL
- Bulk update post slugs through database
- Adding parent pages to posts
- Plain permalinks not working!
- How blog page in WordPress works : blog page retrieve first post ID
- Removing rel=”nofollow” from links posted in Post Content
- How to change permalink on post click on post listing page
- Paginated Posts – Social Media Buttons Share First Page URL
- Changing Permalinks for Default Post type to reflect navigation
- Post-ID in url differs from $post->ID
- Why is my Blog Page ID == First Post ID?