0

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;
0

Ok 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;
?>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.