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
- How to add category to: ‘wp-admin/post-new.php’?
- Use category base slug in posts’ permalink
- Get current post id in functions.php
- How to automatically generate a unique random slug
- Custom permalink structure only for default posts
- Change the Slug of Post Type post to baseurl/post/%postname%
- Different permalink for posts and authors
- Open WordPress ‘Add New Post’ admin page with parameters set via $_GET
- Keep getting same permalink with WP_Query?
- How to control which category will be picked for the slug of a post?
- Change slug with custom field
- Are all ID’s used unique?
- How to get the post id from a permalink?
- Must permalinks always point to single post pages?
- Post in Multiple Categories to stay in current category (permalink, next previous post link)
- get post id in while loops outputting page id
- Undefined variable post_id in custom quick edit coloumn
- Permalink Settings: optional settings doesn’t apply to editor
- How to change the page break URL from ../post/2 to …/post/page2/
- Getting post id from wp_insert_post_data function?
- Does an article (post) id ever change?
- How to get the post’s parent ID?
- Is there a better, more efficient way to get the post id outside the loop?
- Getting current post ID in functions.php
- Random post category URL
- Bulk update post slugs through database
- 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
- current post with current author
- Assign category to new post via URL
- How to get next post ID?
- After database migration, posts not showing up in dashboard
- filter RSS feed in URL
- How could I change my Permalink from blog to custom structure? [closed]
- Start post pagination at 0 instead of 1
- How do I Redirect a WordPress Page?
- How to I retrieve the ID from the Posts page?
- Crazy Question – Updating Post ID
- Second get_permalink inside loop points to wrong URL
- Why I can not I use the variable outside my function?
- retrieve permalinks of posts inside custom post type by using post ID
- register_post_type permalink
- Accessing Post ID Within Loop
- Are post, page and category IDs unique to each other?
- linking to post outside the loop
- Post titles and thumbnails as links to custom post types?
- Inserting Media to WordPress Posts
- Custom Post Type, post-formats associated to custom post type > 404 archives
- Internal linking to posts permalink fail because of spaces and stripe at postname
- Get a post’s ID
- how to create a sub section in posts
- Categories Listing and Highlighting current category item
- How to get the post id (of the parent custom custom type) in a loop inside a widget?
- Get post slug and match with menu item slug to change css
- Private post caught in endless redirect loop
- How to generate an HTML link automatically from URL in a users’ post
- How to give priority to page than to posts permalink structure?
- Only get post_id [duplicate]
- Post URL duplication adds numerical value
- structure of posts and pages
- Post as frontpage – avoid duplicate content
- Custom URL Structure for posts with subcategories
- How can I display a specific number of post in a category via a url
- Is there a way to change the complete URL of the blog post for a redirecting tracking link?
- WordPress with static posts page and custom permalink structure doesn’t find posts with numeric permalinks
- Can’t seem to replicate permalink structure for localhost development site
- Create custom URL with different levels
- My posts section for logged in user
- Make assigning post to a specific category equivalent to assigning it to all categories
- How to mix pages and sub-categories in a url
- Changing permalink of custom category
- Overwrite URL on blog posts
- 301 Redirecting posts without %postid% (just %post_name%) in permalink to ones with %post_name%_%postid%
- How do I add /blog/ on my permalink without affecting the portfolio project types permalink?
- Permalink remain the same on each page
- Can I get custom post items in select box (dropdown)
- After the local installation of an old WP website I can see the homepage but I can’t access to the articles, why?
- Do I need to create a multisite for querying posts from multiple WordPress sites?
- View post with specific category id and name which I selected in the backend (drop-down option)
- How can I fixe the article title problem?