Using WordPress, I need to generate an array of tags(terms) from posts in a particular category.
For instance, if I have two categories, “apple” and “orange”, I want an array of terms that are only used in posts in the apple category — not in the orange category. (though, if a term is used in both, that should be included)
I’ve tried using a handful of wordpress functions, but none return what I want (including tag_cloud function). My guess is I’m left with a Query call … but so far all my queries aren’t giving me the list I want.
Thanks in advance for your help.
I’m not sure you can accomplish what you want using the functions WordPress provides. Here’s an SQL query that seems to do what you want:
The gist of it is that you join the wp_posts table with the taxonomy tables a couple times to get the post IDs in your desired category and then join those IDs with the taxonomy tables a couple more times to get the related tags.