I have built a template and two partials in WordPress (php). In the template I use get_template_part() two times but only the first one is loaded.

    <div class="partial_blockarticle">
        <?php
          get_template_part('partials/blockarticle');
        ?>
    </div> 
    <div class="partial_interview">
        <?php
          get_template_part('partials/interviewpartial');
        ?>
    </div>

In this example, the blockarticles are loaded but no interview. If I switch the divs, only interviews are loaded.

The blockarticles/interviews are Custom Fields and are loaded in the partials like this:

    <?php
    $pageID = $post->ID;
    // Build WP_Query() argument array
        $news = new WP_Query(array(
            'posts_per_page' => 6,
            'post_type' => 'blockarticles',
            'order' => 'desc',
            'orderby' => 'date',
            'meta_key' => 'blockarticle_page_parent',
            'meta_value' => $pageID 
        ));
        while($news->have_posts()): $news->the_post();
    ?>
    //Do stuff

What am I doing wrong here? $news can not be empty since it shows both articles and interview when I switch place?

Read more here: Include several partials in a wordpress template. Showing only one of them


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: