How to query custom posts using a dynamic category

If it is a category page, you can get the id of the current category by using get_category:

 $category = get_category( get_query_var( 'cat' ) );
 $cat_id = $category->cat_ID;

EDIT: You could use the variable $cat_id inside your query instead of ‘Bristol’ and it would pull the correct category for each page.

Leave a Comment