Messed up the global post with query_post
-
I made the mistake of using query_post for the ‘press-release’ section and not resetting it and I’ve been trying to get back for days now, trying different things.
To start with I kept getting the results from the ‘media-coverage’ category when I tried a different way and now nothing seems to work – just blank all the time.
Here is the code now:
<?php if ( ! is_page( 'press-releases' || 'media-coverage' )) { ?> <div class="col-xs-12 col-md-9"> <?php while ( have_posts() ) : the_post(); get_template_part( 'template-parts/content', 'page' ); endwhile; ?> </div> <?php } ?> <?php if ( is_page( 'press-releases' )) { ?> <div class="col-xs-12 col-md-9"> <h1>Press Releases</h1> <?php $query = new WP_Query( array( 'category_name' => 'press-release' ) ); while ( $query1->have_posts() ) { $query1->the_post(); echo '<li>' . get_the_title() . '</li>'; } wp_reset_postdata(); ?> </div> <?php } ?> <?php if ( is_page( 'media-coverage' )) { ?> <div class="col-xs-12 col-md-9"> <h1>Media Coverage</h1> <!-- another query will need to be here for Media Coverage articles --> </div> <?php } ?>
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Messed up the global post with query_post’ is closed to new replies.