Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 2 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,

http://codex.wordpress.org/Function_Reference/query_posts

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

Your Answer

 
discard

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.