I basically want to use WP_Query to select 3 latest posts which have featured images and this is the only way I can think of.
regards
edit
tried
$query = new WP_Query( array( "post_type" => 'case-study', 'meta_key' => '_thumbnail_id', "posts_per_page" => '10', 'orderby' => 'menu_order' ) );
which doesn't work
I'm trying to add a custom field to add a hidden custom field to a post when there is a featured image attached (either true or false).
I've tried hooking into updated_post_meta, update_post_meta, wp_insert_post but I cant seem to match the $meta_key to "_thumbnail_id".
edit
function get_latest_with_featured_image( $args = array() ) {
$args = array_merge( array( "post_type" => 'post', "meta_key" => "_thumbnail_id", "posts_per_page" => '10', 'orderby' => 'menu_order' ), $args );
$query = new WP_Query( $args );
return $query->posts;
}
$posts = get_latest_with_featured_image( array( "post_type" => "case-studies", "posts_per_page" => 10 ) );
$query
for your custom query. I would name it something descriptive. But more importantly: did you add post-thumbnail support to yourcase-study
post-type? Do you havecase-study
posts that have featured images attached?