display posts under specific page
I a开发者_Go百科m having many number of pages, I would like to display some specific posts under one specific page. for example Under News page i need to display only news related posts only
how to do this?
This is a new query, won't effect the main Wordpress loop and can be used multiple times on a page. Change parameters to your category name and number of posts to show. Use in a page template or in page editor with php execution enabled.
<?php $my_query = new WP_Query('category_name=mycategory&showposts=1'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php the_title(); ?></a>
<?php the_content(); ?>
<?php endwhile; ?>
精彩评论