Does not work with custom taxonomies
-
The UI of this plugin is very misleading. When editing conditions for a menu you are presented with ALL possible taxonomies. However, if you choose to base your conditions on a custom taxonomy you’re up for disappointment (and possibly confusion).
There is absolutely no logic implemented in the plugin for custom taxonomies (I’ve verified this by reading the source code and also stepping through the running code using a debugger).
I had to write the code for custom taxonomies myself and added the following inside the
if(is_singular())
block, around line 270 or so:// Test for custom taxonomies $post_taxonomies = get_post_taxonomies(get_the_ID()); foreach ($post_taxonomies as $post_taxonomy_name) { if (isset($logic['tax'][$post_taxonomy_name])) { $logic_term_slug = array_keys($logic['tax'][$post_taxonomy_name])[0]; $post_terms = get_the_terms(get_the_ID(), $post_taxonomy_name); if ($post_terms) foreach ($post_terms as $post_term) { if ($post_term->slug === $logic_term_slug) { $visible = true; } } } } // -- end test for custom taxonomies
Disclaimer: The code above was custom made to solve my particular problem and was tested only in that situation. It is not meant to be generic and is not thoroughly tested. Although it might work for you, don’t just copy/paste the code unless you know what you are doing.
I would kindly ask the developer Themify to either:
- Preferably: Add code to the plugin to actually check all possible conditions, including custom taxonomies, custom post types etc. Feel free to use the code above as a starting point if that helps.
- Or at the very least: Update the UI so that only the taxonomies etc that the plugin actually respects are presented when editing conditions.
- The topic ‘Does not work with custom taxonomies’ is closed to new replies.