Limit get_terms to Posts in Query

Every now and then we need to create a list of taxonomies that are not just empty, but are also not found in the posts for that page.

I recently found a pretty sweet solution over on Stack Overflow and wanted to share.


Multiple WP Dropdown

Thanks to Stack Exchange user MahdiY!

See original here.

In functions.php

When using wp_dropdown_categories just add the “multiple” argument:



Taxonomy Description WYSIWYG

On sites where we are using custom post type taxonomies, we often want to have archive page. The problem, is the description field for a taxonomy is a simple textarea field. WE WANT MORE! Here is the code needed to replace the “Description” textarea field with a WYSIWYG field.

This was stolen verbatim from qwerty qwerty over on WordPress StackExchange.

Force Parent Taxonomies

Taxonomies are fantastic, but for some reason there is no built in method for forcing WordPress to select all parent terms of a taxonomy if a user only selects a child / grand-child term. We found a sweet method to force any selected taxonomy to also select all parent taxonomies as well. Thanks to the WordPress Stack Exchange user Sisir for this sweet function.


Disable Taxonomy Archive

Sometimes we do not want our custom taxonomies to have archive pages. Lots of reasons for this, yet there doesn’t seem to be a good solution for this. I would love to see WordPress implement a ‘has_archive’ flag for taxonomies someday. Until then we can use this function to return a 404 for any taxonomy archives we do not want shown to users.


Using Multiple Taxonomies in ACF Repeater

I was trying forever to get a good way to allow a user to select from multiple different taxonomies in one ACF drop down. I eventually realized that is just not possible.

Instead, what we need to do is use a select field and populate it dynamically.

To do this, simply create a select field in your ACF. I ended up doing this inside of a repeater, like so:


Now we just need to populate this select field to simulate our taxonomy field. Here is the code for that:

There we go! Now you have a select field that allows the user to select between two ( or more ) taxonomies!