作为对@Pippin答案的补充:
甚至可以使用一个语法略有不同的查询。
// Get all post types
$post_types = get_post_types(
array(
\'public\' => true
// Avoid attachments - those aren\'t shown in the admin menu
,\'show_in_menu\' => true
)
,\'names\'
);
// Get rid of unwanted post types
// Use the array to add your unwanted post types
foreach ( array( \'some_unwanted_post_type\', \'another_one\' ) as $not_me )
in_array( $not_me, $post_types ) AND unset( $post_types[ $not_me ] );
// Group by filter
add_filter( \'posts_groupby\', \'wpse57806_posts_groupby\', 20 );
// Query posts - Two options for post_types
$items = get_posts( array(
\'post_type\' => $post_types
// ... or ...
# \'post_type\' => \'any\' // every post type, but not attachments
,\'posts_per_page\' => count( $post_types )
) );
// Call the thumbnail
foreach ( $items as $item )
echo get_the_post_thumbnail( $item->ID, \'thumbnail\' );
编辑您需要一个小的回调函数来进行编辑:
function wpse57806_posts_groupby()
{
// only needed once - better kept in here
remove_filter( current_filter(), __FUNCTION__ );
return \'post_type\';
}