WP_Query Check if post has one or more attached medias

I’m afraid that it’s not possible by default. Using WP_Query you can only check if posts have a featured image set. What you can do instead: Create a hook that fires during post save (e.g. “post_updated”), check if this post has any attachments – save this information in post_meta. Use meta_query with WP_Query to get … Read more

filter custom post type by meta key in dashboard

I’m assuming you’ve used the method in the question linked to and are using the restrict_manage_posts filter. add_action( ‘restrict_manage_posts’, ‘my_search_box’ ); function my_search_box() { // only add search box on desired custom post_type listings global $typenow; if ($typenow == ‘product’) { //On custom post type ‘product’ admin page. //Add code for search box here } … Read more