WordPress.org

Ready to get started?Download WordPress

Forums

Trying to show only ONE category post in page template (3 posts)

  1. yaptalk
    Member
    Posted 1 year ago #

    Hello, I am trying to show a single category in a new template page I created (using a few tutorials)

    For the life of me, I can't get it to show only the posts in a single category (category 26).

    Right now the page template works but it shows ALL the categories posts instead of the one category I need.

    This is my code that calls the posts

    <?php
    
    	    	$post = $wp_query->post;
    
    	   	 	$limit = get_settings('posts_per_page');
    
    			$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    			query_posts('showposts='.$limit.'&paged=' . $paged);
    
    			while (have_posts()) : the_post(); 
    
    			?>

    Does anyone know what I am doing wrong? Any help will be greatly appreciated.

  2. yaptalk
    Member
    Posted 1 year ago #

    FIXED

    Replaced

    query_posts('showposts='.$limit.'&paged=' . $paged);

    with

    query_posts("cat=$26&paged=$paged");

    and now the template I made only shows one category's posts!

  3. stevelack
    Member
    Posted 9 months ago #

    Thanks for posting the answer. This was exactly what I was looking for. I appreciate that you followed up on your own question!

Topic Closed

This topic has been closed to new replies.

About this Topic