Support » How-To and Troubleshooting » [Resolved] Category Specific Template
7 years, 9 months ago
I am attempting to create a page template that calls for just one category as opposed to calling all posts.
Could someone advise on how to do this?
I am assuming that I need to add code somewhere in here?:
$temp = $wp_query;
$wp_query = new WP_Query();
if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();
global $more; $more = 0;
<h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<p><?php the_time('F j, Y'); ?></p>
<?php the_content(); ?>
in your template file where you want to show it.
I specifically want to call just one category, the code I posted calls all of the posts. What do I need to alter in the code I posted to call just, let’s say, category 5 for instance?
$my_query = new WP_Query("showposts=1&category_name=News");
$my_query = new WP_Query("showposts=1&cat=5");
Thank you. That did it.