wp query – In a WP_Query can I force the results’ is_singular() to be set to false?
I have a custom page template that includes a basic query after the main content. like this:
$myPosts = new WP_Query( array( 'post_type' => array('post', 'contentTypeA', 'contentTypeB' ), 'posts_per_page' => 10, 'order' => 'DESC', ) ); if ( $myPosts->have_posts() ) : while ( $myPosts->have_posts() ) : $myPosts->the_post(); get_template_part( 'template-parts/content', get_post_type() ); endwhile; endif; wp_reset_postdata();
My problem is that the results think that they are single pages. The template part linked by
get_template_part() has a condition that if
is_singular() is true, among many other things, render the title as
<h1>, otherwise render as
In my WP_Query feed, all the results are using
<h1> for titles because
is_singular() is registering as
true for the posts.
So, my question is: is there an argument I can pass to my WP_Query to force the results to think that
false? In other words, to make this output like a standard archive page.
I have discovered that if I use
if ( is_singular() && in_the_loop() ) : it sort of does the trick, but I am hoping there is a much simpler solution than adding that to the dozens of template partials I have that rely on