query_posts for category
-
I am working on a theme that uses query_posts. For the category page, I am trying to show posts that are just in that category. I tried the following code that I found on this page but it does not work.
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Replace any spaces in the title with dashes $title_slug = strtolower(str_replace( " ", "-" , the_title_attribute('echo=0') ) ); // Get the category object by using our new title slug $id_obj = get_category_by_slug($title_slug); // Get the category id so that we can use that in the query $cat_id = $id_obj->term_id; query_posts('post_type=post&posts_per_page=5&cat='.$cat_id.'&paged=' . $paged); ?>
Any suggestions? I would really appreciate it.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘query_posts for category’ is closed to new replies.