foreach all the post

Your code has many errors:-

  • $thumbs isn’t used anywhere.
  • $img_url = $thumb['url']; undefined variable
  • if(is_array($thumb) && $img_url) always false because of second point.
  • $search_data = []; should be outside of loop.

Check the correct part of code

$search_data = [];
if($query->have_posts()):
    while($query->have_posts()):
        $query->the_post();

        $img_url = get_the_post_thumbnail_url();

        if(!empty($img_url)){
            $search_data[] = array(
                'name' => get_the_title(),
                'thumb' => $img_url,
                'desc' => get_the_content()
            );
        }       
    endwhile;
endif;

NOTE: get_the_post_thumbnail_url() is only available from WordPress
4.4