0

I want to run two queries right after each other. Both queries return posts on their own. When I have both of them after each other, only the first one returns results.

I've tried wp_reset_postdata(), wp_reset_query(), and even rewind_posts(), yet I'm always getting no results on the second query. What am I missing? Thanks so much.

<?php  
$va_args = array( 
    'post_type' => 'release', 
    'numberposts' => -1,
    'posts_per_page' => -1, 
    'meta_query' => array(
        array(
            'relation' => 'AND',
            array(
                'key' => 'variable_one', 
                'value' => 'yes',
            ),
            array(
                'key' => 'variable_two', 
                'value' => 'no',
            ),
            array(
                'key' => 'select_artists', 
                'value' => $parent_id,
                'compare' => 'LIKE',
            ),
        ), 
    ),
); 
$va_query = new WP_Query( $va_args ); 
if ($va_query->have_posts()){?>
    <section>  
        <br>
        <h1><span class="yellowText"><u>First Variable Section</u></span></h1>
                <?php 
                if($va_query->have_posts()) :
                while ( $va_query->have_posts() ) : $va_query->the_post();
                    include get_template_directory() . '/includes/containers/master-container.php' ;
                    echo '<br>';
                endwhile;
                endif; 
                ?>   
    </section>
<?php } //end of if  has posts
wp_reset_postdata(); ?>
<?php
$va_st_args = array( 
    'post_type' => 'release', 
    'numberposts' => -1,
    'posts_per_page' => -1, 
    'meta_query' => array(
        array(
            'relation' => 'AND',
            array(
                'key' => 'variable_one', 
                'value' => 'yes',
            ),
            array(
                'key' => 'variable_two', 
                'value' => 'yes',
            ),
            array(
                'key' => 'select_artists', 
                'value' => $parent_id,
                'compare' => 'LIKE',
            ),
        ), 
    ),
); 
$va_st_query = new WP_Query( $va_st_args ); 
if ($va_st_query->have_posts()){?>
    <section> 
        <br>
        <h1><span class="yellowText"><u>Second Variable Section</u></span></h1>
                <?php 
                if($va_st_query->have_posts()) :
                while ( $va_st_query->have_posts() ) : $va_st_query->the_post();
                    include get_template_directory() . '/includes/containers/master-container.php' ;
                    echo '<br>';
                endwhile;
                endif; 
                ?>   
    </section>
<?php } //end of if has posts
wp_reset_postdata(); ?>

0

Your Answer

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