2 hours ago · Tech · 0 comments

WordPress has the concept of "Featured Images". They are the images which show up when you share a blog post on social media or, on some themes, as the "hero" image. How can you quickly and easily find any posts which don't have a featured image? For this, I use WP CLI - it allows you to run complex WordPress actions and queries using the command line. After you have installed WP CLI you can get started. Missing Images On the command line, run: wp eval 'foreach(get_posts(array("post_type"=>"post","post_status"=>array("publish"),"posts_per_page"=>-1,)) as $post){if(get_the_post_thumbnail($post)==""){$post_type_object=get_post_type_object($post->post_type);$link=admin_url(sprintf($post_type_object->_edit_link . "&action=edit", $post->ID));echo $post->post_date . " " . $link . " " . $post->post_title . "\n";}}' Here's the code in a slightly more readable format: foreach ( get_posts( array( "post_type" => "post", "post_status" => array("publish"), "posts_per_page" => -1, ) ) as $post) {…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.