wordpress query exclude posts with empty category

56 Views Asked by At

I am making a pre_get_posts search query.

But i want to exclude posts if they have no author.

How do I do this? See first setup below. But I don't know how to exclude posts with empty authors. Thanks in advance!

function query_search_allposts( $query ) {
   if ( $query->is_search  ) {
    if ( isset($_GET['post_type'] ) ) {
      
            $query->set( 'posts_per_page', 12 );
        }
       
   }
}
add_action( 'pre_get_posts', 'query_search_allposts' );
0

There are 0 best solutions below