August 5th in Wordpress by .

WordPress – How to get category ID for use in category.php

Getting the category ID of inside of category.php or archive.php seems very easy, i struggled 3hrs to get this working.

I wanted to put up a custom query_posts() function inside category.php and the only way it works is

$cat = get_query_var(‘cat’)

You have to combine this with query_posts function

query_posts(‘cat=’.get_query_var(‘cat’) . ‘&posts_per_page=3′);

Amazingly simple isnt it!

Similar Posts:

Leave A Comment.





Please wrap all source codes with [code][/code] tags. Powered by