I made a loop which is loading post-type. But while it is loading basic post and post-type, it is not loading the main content of the page. I am searching for a way to load the current page content while loading my post-type.
How can I do that ?
global $wp_query;
$args = array_merge( $wp_query->query, array( 'post_type' => array('post','Projets'), 'posts_per_page' => 3, ) );
if ( query_posts($args) ) :
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', 'content' )
endwhile;
else :
get_template_part( 'template-parts/none', 'none' );
endif;
I made a loop which is loading post-type. But while it is loading basic post and post-type, it is not loading the main content of the page. I am searching for a way to load the current page content while loading my post-type.
How can I do that ?
global $wp_query;
$args = array_merge( $wp_query->query, array( 'post_type' => array('post','Projets'), 'posts_per_page' => 3, ) );
if ( query_posts($args) ) :
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', 'content' )
endwhile;
else :
get_template_part( 'template-parts/none', 'none' );
endif;
Share
Improve this question
asked Apr 7, 2020 at 16:52
YagayenteYagayente
1011 bronze badge
1 Answer
Reset to default 0Ok solved it like this :
<?php
$mainquery = get_queried_object();
$args = array(
'pagename' => 'Accueil' //as my home page
);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
?>
<div class="entry-content">
<?php
the_content(); // here I can load my content
?>
</div><br><br>
<?php
}
}
wp_reset_postdata();
global $wp_query;
$args = array_merge($wp_query->query, array(
'post_type' => array(
'post',
'Projets'
),
'posts_per_page' => 3
));
if (query_posts($args)):
while (have_posts()):
the_post();
get_template_part('template-parts/content', 'content');
endwhile;
else:
get_template_part('template-parts/none', 'none');
endif;
?>