1

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!

1 Answer 1

5

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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