This should work for you:
// grab all public post types
$post_types = get_post_types( array('public' => true), 'names' );
// loops through each post type
foreach( $post_types as $type ) {
// setup the query
$query_args = array(
'post_type' => $type,
'posts_per_page' => 1
);
// perform the query
$items = get_posts( $query_args );
// check if we have found anything
if( $items ) {
// loop through the items
foreach( $items as $item ) {
// show the post thumbnail
echo get_the_post_thumbnail( $item->ID, 'thumbnail' );
}
}
}
Related Posts:
- Create a custom archive page for a custom post type in a plugin
- Custom Post Type Archive Page not showing
- Custom post type yearly/ monthly archive permalinks
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Page is defaulting to archive page and not designated template
- custom post type archive page url to point to Page permalink
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Add Settings to Custom Post Type
- Custom post type permalink structure with the category also acting as an archive
- Custom Post Type Works but Still Shows “Page Not Found”
- Rewrite custom post type url’s adding meta box values
- I can’t set meta_key in my custom post type query
- Hide child term posts on parent term pages
- Compare 3 custom fields and sort by oldest
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Archive page for taxonomy of custom post type
- Add meta data to the custom post type ARCHIVES page
- Custom post type archive sorted and grouped by date in post meta field
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- Custom Post Type archive giving 404
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- Custom query variable – get wordpress to redirect to nice permalink url
- Custom-post-type-archive: posts sorted/filtered by year?
- add_rewrite_endpoint() and Custom Post Type Archive
- Custom post type archive page pagination
- Add the current menu item CSS class to a custom page type archive in WordPress menu
- Add custom post type archives to search results?
- How do I get the permalink structure to work like this?
- How to use WP_Query in a CPT achive page?
- Have a Custom Post Type index page display taxonomy items instead of posts
- WP_Query | ‘post_type’ doesn’t work
- Editable Meta Data for Custom Post Type Archive Template
- Query var removed after rewrite
- Custom Post Type with has_archive ignores my custom archive and single template
- Archives for Custom Post Types (without Pages)
- Unable to get post archive link
- Custom Post Type archive loop separated by term, in specific term order
- Show only posts from one category on custom post type archive page
- Extending AZIndex plugin to use custom post types and custom taxonomies
- Display custom post type category, while in a CPT category, then the posts beneath
- How to display custom post in archive section of the wordpress page?
- Custom post type archive with page as parent url
- Custom post type, global categories — what’s the template name?
- Set thumbnail and title for a post type archive (not post itself!)
- Url to archive page for custom post type
- Return the name of the post type
- How to integrate single and archive templates for custom post type in any WordPress theme
- Show categories of custom post type and not all posts
- adding custom post type “name” to single template
- Custom Post Type Archive template not being called
- Custom Post Type with Configurable Sidebar via ACF
- Query Posts that have Custom Taxonomy
- Archive page for custom post type and custom taxonomy
- Order Custom Post Type Archive by multiple values in functions.php
- Pagination does not work on Custom Post Type archive while trying to get load more function working
- How to have multiple archive pages?
- Displaying custom taxonomy menu in custom post type archive
- Create a Custom Path to Archive
- WordPress sitemap with Custom Post Types
- Is possible register two archive pages for single custom post type?
- Display All Courses in Course Archive Page
- Archive page of CPT’s custom Taxonomy
- Getting Same Description in All the Custom Taxonomy Posts
- Archive page for WordPress Custom Post Type doesn’t show pagination from paginate_links()
- Custom post type archive URLs with a single taxonomy
- Custom post type author issues
- Custom Post Type / Taxonomy not displaying archive
- pagination problem listing custom post types of taxonomy in wordpress
- ACF Pro Accessing fields on a Custom Post Type
- Do not show child pages within a file page
- Permalink for custom post type pages not working
- Set archive of custom post type like ‘posts’ page in reading settings is set
- Custom taxonomy with custom post type archive page
- Meta_query by date for Events archive
- Custome post type “tags” pick default archive instead of custom post type archive
- Customize url from the_terms
- Want to display my custom date archive to date.php but dont know how
- Help with Multi Level Category Archive Page
- Custom post type archive page not showing on archive-posttype.php
- Highlight a Post on archive page if it has a new comment?
- Display custom post type archive on page.php template
- Pagination fault in custom post type archive page [duplicate]
- Templates list in “Page Attributes” metabox is inaccurate
- Stop Custom post type from being searched via URL
- Permalink of custom post type partly broken
- Custom Post Type Archive Links Not Working
- CPT archive as home page
- Archive page of filtered posts
- Why is this custom post type defaulting to archive.php?
- title tag for custom post type remove taxonomy name from title tag
- Archive Page Pagination not working
- Custom taxonomy archive page not routing?
- single-mySlug.php works: archive-mySlug.php does not. Custom Post Type
- has_archive for default post type
- Pagination not working for archive
- Pagination for Custom Post Type with Multiple Types
- Custom Post Type Archive Title Lowercase
- Pagination not working only on Archive-Name.php using new WP_Query
- Can’t add custom post type archive page to menu