Normally WordPress default functionality display all posts of all category, But if we need to display only posts of certain or one category, Use the below code.
Replace '2' with your Category id.
<?php query_posts('cat=2'.'&orderby=date&order=asc'); ?> // 2 is the Category id
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
Replace '2' with your Category id.
<?php query_posts('cat=2'.'&orderby=date&order=asc'); ?> // 2 is the Category id
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
No comments:
Post a Comment