Allow for non-public taxonomies to be used for posts filtering

I really love the utility files and classes that create the whole query filtering UI. However, that and FLBuilderLoop discard any taxonomies that are not public OR have show_ui set to false. While I understand where this is coming from, I don’t think it’s that uncommon to have taxonomies that are used for categorizing posts but are not used with WordPress’ native archive pages.

Here’s an example I’m working on at the moment - I have a Team post type with a taxonomy for departments. Instead of doing separate pages for each department(as there aren’t that many people), I’m doing a single page and building a custom module that will display info about each person. The administrator can filter by the department taxonomy to display members in multiple columns or whatever layout they want via Beaver Builder.

So far I had to create a custom version of loop-settings.php as it didn’t list the department taxonomy. I now just realized that FLBuilderLoop also discards the taxonomy parameters, so I’ll have to duplicate that as well.

In my opinion there should be an easier way to allow for non-public taxonomies to be used within modules than having to duplicate code.

Obviously it won’t be acceptable if a single plugin decides to make non-public taxonomies available to all modules, just because it has one module that needs the feature, so the solution would have to be via filters that pass information about the current module(not sure how that would work with FLBuilderLoop, but it should be fairly trivial to do with loop-settings.php).

Hi Nikola,

I’ve already assigned another member of the team to assist you with your concern.

Jun

Hi Nikola,

What if we give you a way to filter the return value of FLBuilderLoop::taxonomies? That would allow you to add back in any taxonomies that were removed.

You could also add that filter in your module and then remove it after your query has run. I believe that should work.

Let me know what you think.

Justin

Yes, something like that would be awesome :slight_smile:

Within that filter you can pass the post type’s slug as well so that I can use the built-in loop-settings.php(as it also calls FLBuilderLoop::taxonomies()) and then I wouldn’t have to duplicate any code whatsoever(just add a quick filter).

Hi Nikola,

You got it! I’ll get this into 1.7.7 that’s going out next week. For now, feel free to change the return value of FLBuilderLoop::taxonomies to…

return apply_filters( 'fl_builder_loop_taxonomies', $data, $taxonomies, $post_type );

I added the original $taxonomies array so you don’t have to query those again.

Let me know if you have any questions.

Justin

That’s awesome! I really appreciate the quick implementation of the suggestion.

Keep up with the awesome work you’re all doing!