Hello! There was a certain problem when displaying the last posts on the main page of the site, for example: I have news, the last page displays the last two, but they should be there only with pictures, but not necessarily in each news entry there will be a picture, actually a question , how to select from the database only those that have "featured image". Thanks!)

    2 answers 2

    $args = array( 'posts_per_page' => 2, 'post_type' => 'post', 'orderby' => 'date', 'order' => 'DESC', 'meta_query' => array( array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS' ) ) ); $query = new WP_Query( $args ); 

    Source (see "# 5 Get records that have an arbitrary field")

    • Thank! It worked) - russell

    Page-list plugin [pagelist_ext show_content = "0" image_width = "200" image_height = "200"]

    • Try to write more detailed answers. - Vadim Ovchinnikov