Globally filtering posts by Custom Taxonomy
-
Hello!
On our site we want to add the possiblity for the user to choose the content (s)he would like to read about the most. Therefore, I added a simple form which displays all terms of our custom taxonomy (which is assigned to a custom content type).
Once the user made his/her choice, the term ids are saved in a COOKIE.What I need now is a hook to change *all* queries to reflect the user’s preference.
Example:
I have a custom content type called “News”. This content-type has a custom taxonomy called “Flowers”. The taxonomy has different terms (e.g. colours) like: Green, Blue, etc. On the front page the user chose to only see News (the content type) that have the term “Green” assigned to the taxonomy “flowers”. This is now the global setting. Whenever a list of news is being displayed it filters out all entries that do not meet the requirements.
Is this even possible like that?
I tried finding some useful info on the “Custom Queries”-Codex page and also checked the pre_get_posts / found_posts hooks/filters to no avail.
pre_get_posts sounds perfect, but can it work with custom taxonomies?
Any help is much appreciated. Thanks!
- The topic ‘Globally filtering posts by Custom Taxonomy’ is closed to new replies.