I have gone through the process of creating a custom taxonomy + admin panel for a custom post type in my site. These taxonomies store various meta data in a wp_taxonomymeta
table and use get_metadata/set_metadata to get and set the values of these fields. One of the fields in this taxonomy is an enabled/disabled flag.
I would like to globally exclude posts that have the disabled flag set to true. I am hooking into pre_get_posts
, but I cannot figure out how to modify the query so that I can pull data in the wp_taxonomymeta
for use in the query to exclude posts that should be hidden. Can anyone provide some insight into doing this? I could not find much helpful advice on google. If clarification is needed, please ask, I will do my best to clear anything confusing up.
EDIT FROM COMMENTS
I'm trying to modify the main query. The idea is ultimately to be able to hide/show globally across the site based on the taxonomy's meta data flag value. So I have a plugin that implements a pre_get_posts
hook, but I cannot get the query figured out with the custom table (at least in the typical wordpress fashion, raw SQL would be cake, but I'm wanting to modify the main query).
There's not a lot of documentation around for working with these taxonomy tables since it seems to be a disputed way of doing stuff in wordpress.
WP_Query
's custom parameters so long.