I have three pages on my site. Name them at home, page 2 and page 3. My "home" page is set as a static front page. My page2 is configured as a blog page.
I want the following:
I want page2 to display blog posts with a specific category (of which ID is known).
and
I want page3 to display blog posts with a specific category (of which ID is known).
The PHP code that only shows messages with a specific category (or, in my case, actually shows messages, excluding two categories) is as follows:
<?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>
Now, in my page.php, I have the following code to display posts with one category:
<?php
if ( is_page('newspaper') ) {
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>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
<?php
}
?>
( .3 ). ( index.php).
EDIT: ( ). index.php:
<?php
if ( is_page('newspaper') || 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>
<?php the_excerpt('Read the rest of this entry »'); ?>
</div>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
<?php
}
?>
, , ...
( ). , ?
!
Amit