Support » Fixing WordPress » Category Specific Template

  • Resolved archaeologyman

    (@archaeologyman)


    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?

    Thanks.

    I am assuming that I need to add code somewhere in here?:

    <?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=5'.'&paged='.$paged);
    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(); ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • lifestyler

    (@lifestyler)

    in your template file where you want to show it.

    archaeologyman

    (@archaeologyman)

    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?

    Thanks.

    $my_query = new WP_Query("showposts=1&category_name=News");

    or

    $my_query = new WP_Query("showposts=1&cat=5");

    archaeoman

    (@archaeoman)

    Thank you. That did it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category Specific Template’ is closed to new replies.