Reputation: 3224
I added a new piece of code to my header.php
now the content for my Pages aren't being shown.
In my index.php
main tag i have this code
<?php if(!is_home() || !is_front_page) { // dont display on home page
if ( have_posts() ) : while ( have_posts() ) : the_post();
the_content();
endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif;
} ?>
now since adding the code below to my header.php
, the_content for my Pages aren't being displayed. e.g. About, Contact etc
<?php
query_posts('cat=Gallery');
while (have_posts()) : the_post();
the_content();
endwhile;
?>
The code in header.php
is to fetch Posts of a specific category but now the content for my Pages aren't being displayed. Where did i go wrong?
Upvotes: 0
Views: 258
Reputation: 7611
query_posts()
replaces the posts retrieved by WordPress - have a look at the Codex page.
Try using get_posts()
instead.
It might also be worth calling wp_reset_query()
after your header loop, which can help prevent unexpected behaviour.
Upvotes: 2