if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); // Your loop code here, e.g.: the_title('

', '

'); the_content(); endwhile; // Add pagination the_posts_pagination(array( 'prev_text' => __('Previous'), 'next_text' => __('Next'), )); else : echo 'No publications found.'; endif; // Reset post data after custom query wp_reset_postdata();