Hi all,
I have three pages on my site. Let's call them home, page2, and page3. My 'home' page is set as a static front page. My 'page2' is set up as the blog page.
What I want is the following:
I want page2 to display blog posts with a certain category (of which ID is known).
AND
I want page3 to display blog posts with a certain category (of which ID is known).
The PHP code to only show posts with a certain category (or actually in my case, show posts excluding two categories) is the following:
<?php query_posts($query_string . '&cat=-3,-8'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h3>
<?php the_excerpt('Read the rest of this entry »'); ?>
</div><!-- /.post-->
Now, in my page.php, I have the following code to display posts with one category:
<?php
// BEGIN IF PAGE is newspaper articles page
if ( is_page('newspaper') ) {
//BEGIN POST REGION
query_posts($query_string . '&cat=8'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3><?php the_title(); ?></h3>
<?php the_content('Read more »'); ?>
</div><!-- /.post-->
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
<?php
} //end if is_page
?>
But it doesn't show the proper posts on the newspaper page (or page3 in this question). It does, however, work for the articles page (main index.php blog page).
EDIT: I've also tried the following (but it doesn't work). I put this in the index.php file:
<?php
if ( is_page('newspaper') || is_home() ) { // START if is home
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to
<?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h3>
<!--<p><?php the_time('F jS, Y') ?> <?php //the_author() ?></p>-->
<?php the_excerpt('Read the rest of this entry »'); ?>
</div><!-- /.post-->
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
<?php
} //end if is_home() or is_page()
?>
Again, this shows the posts on the main blog page, but doesn't show any posts on the newspaper page...
The question is therefore simple (I think). How do I show posts on another page OTHER than the main blog page?
Thanks! Amit