That is a very broken Loop. The results of a new WP_Query
is not a simple array that you can foreach
over. It is far more complicated than that. Try var_dump($work_galleries);
.
Fortunately, WP_Query
provides methods to make looping easy.
$work_galleries = new WP_Query($args);
if ($work_galleries->have_posts()) {
while ($work_galleries->have_posts()) { // this replaces foreach
$work_galleries->the_post(); // this sets up the post data so functions like the_title() work
// now your code
}
}