WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to filter my posts by category, then further by city. The only way I can think of filter by city is if the admin adds the city to the listed tags and then filtering from there via switch statement.

How can I filter posts by a certain tag?

Is there a better way to do what I'm doing?

My PHP knowledge is intermediate and my Wordpress knowledge is pretty basic. Thanks in advance!

share|improve this question
up vote 3 down vote accepted

here you go,

The following returns all posts that belong to category 1 and are tagged "apples"

query_posts( 'cat=1&tag=apples' );

Add this inside the page before the loop

change '1' and 'apples' to whatever category and tag you want.

If you must use query_posts(), make sure you call wp_reset_query() after you're done.

look here for more info,


share|improve this answer
Great Thanks!!! – Howdy_McGee Jan 25 '12 at 18:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.