Beautiful taxonomy filters
Your custom post type archives by letting visitors filter posts by their terms/categories.
Install in
The Beautiful Taxonomy Filters plugin is an easy and good-looking way to provide your visitors with filtering for your post types. With this you get a complete solution for adding filtering based on custom taxonomy terms/categories/tags. It will also automatically add rewrite rules for pretty looking filter URLs. It’s completely automatic, works without javascript and is based on the WordPress Plugin boilerplate for a standardized, organized and object-oriented codebase. It uses select2 for pretty looking and user friendly dropdowns but will fall back to ordinary ones if javascript is not supported.
No more horrible looking URLs or hacky Javascript solutions
Try it before installing it. Use the Live Preview button on this page for a temporary WordPress in your browser, already set up with a recipe archive and three taxonomies to filter on. Nothing is installed and nothing is saved. The one thing the preview cannot show you is the rewritten URL itself – see the FAQ for why.
Features
- Activate filtering on any registered public custom post type.
- Exclude taxonomies you just don’t want the visitors to filter on.
- Beautifies the resulting URLs. You won’t see any /posttype/?taxonomy1=term. Instead you’ll see /posttype/taxonomy/term.
- The pretty URLs are much more SEO friendly so you’ll give a boost to those filtered pages. Just remember to use canonicals where it’s appropriate.
- BETA: Conditional dropdowns. Make sure your visitors never end up with empty filtered results. AJAX reloads the values in each dropdown based on previously selected values.
- Polylang compatible.
- Multisite compatible. No network settings at the moment.
- Comes with a complete functional filter module for you to put in your theme.
- Three alternatives for putting the filter modules in your theme:
- Widgets (Also lets you “hard set” a post type for use anywhere)
- do_action hooks (for granular control)
- Automagic setting which will magically place the modules in your archive from thin air. Wizards at work…
- Choose from different styles for the component, or disable styling and do it yourself in style.css! Just want to tweak a style? Add your custom CSS directly on the settings page.
- Many more settings for fine-tuning the filter modules behavior:
- A ”Clear all” link for the filter component.
- Choose between placeholders or “show all” in the dropdowns.
- Hide empty terms in the dropdowns.
- Show a post count next to the term name
- Disable select2
- Show term description
- Disable headings you don’t want
- More to come!
- Ability to show your visitors information about their current active filtering and control the look of this.
- Allows for custom GET parameters to be included. Extend the filter your way with maybe a custom search-parameter or whatever you like.
- Many filters and actions for modifying the plugins behavior. For you control freaks out there…
Languages
- English
- Swedish
- Spanish (Thanks to Juan Javier Moreno Restituto)
- Dutch (Thanks to Piet Bos)
- German (Thanks to Matthias Bonnes)
- French (Thanks to Brice Capobianco)
- Simplified Chinese (Thanks to Amos Lee)
- Portuguese (Thanks to Luis Martins)
- Portuguese Brasil (Thanks to Bruno Sousa)
- Catalan (Thanks to Maiol Xercavins)
- Swiss (Thanks to Raphael Hüni)
- Bulgarian (Thanks to Georgi Marokov)
- Romanian (Thanks to Roberto Tamas)
Do you want to translate this plugin to another language? I recommend using POEdit (http://poedit.net/) or if you prefer to do it straight from the WordPress admin interface (https://wordpress.org/plugins/loco-translate/). When you’re done, send us the file(s) to me@jonte.dev and we’ll add it to the official plugin!
Other
- Based on WordPress Plugin Boilerplate
- Uses Select2 to enhance dropdowns
Featured on
Developer documentation
Every filter and action, with examples, is documented at beautiful-taxonomy-filters.github.io/beautiful-taxonomy-filters.
Written by Joobi from the project's own listing. See the source page
2.6.1
- SECURITY: Fixed a stored cross-site scripting vulnerability (CVE-2026-122298) in the conditional dropdowns AJAX endpoint. A user able to create terms could give one a name that the endpoint returned as live HTML. Term names are now returned HTML escaped and decoded as plain text in the browser, and the response is sent as
application/jsonwith HTML characters escaped. Thanks to Wordfence for the responsible disclosure. Please update. - SECURITY: Term names, slugs and descriptions in the filter dropdowns are now escaped on output, and select2 no longer parses the selected term’s text as HTML when term descriptions are shown.
- SECURITY: The conditional dropdowns endpoint now only answers when conditional dropdowns are enabled, for post types the filter is enabled on, and only about the taxonomies the filter module itself shows. Before, a visitor could ask it for the terms of any taxonomy, including non-public ones.
- SECURITY: All settings are now sanitized when saved, and output from filters such as
beautiful_filters_apply_button,beautiful_filters_loaderandbeautiful_filters_term_nameis passed throughwp_kses_post(). Admin strings are escaped too. - BUGFIX: Conditional dropdowns no longer return nothing for taxonomies with a hyphen in their name. If you modify the query with
beautiful_filters_related_terms_sql, note that the joined tables are now aliasedbtf_tr0,btf_tr1and so on. - BUGFIX: Filtering with a term that doesn’t exist (anymore) no longer produces a broken URL and PHP warnings. Custom GET parameters carried over to the filtered URL are now properly encoded.
- BUGFIX: The conditional dropdowns endpoint no longer calls
map_deep(), which doesn’t exist before WordPress 4.4, the plugin’s minimum supported version being 4.3. - IMPROVEMENT: Every PHP file now refuses to run when requested directly instead of through WordPress.
- IMPROVEMENT: Rewrite rules are flushed when you save the post types or taxonomies settings, instead of every time the settings page is viewed.
- IMPROVEMENT: The filter widget now skips non-public taxonomies, like the filter module already did.
- IMPROVEMENT: The plugin’s scripts (select2 included) are now only loaded on pages that actually show a filter module, whether that’s through automagic, the shortcode, the
show_beautiful_filtersaction or the widget, and they load deferred. Pages without a filter no longer download them. - NOTE: The stylesheets are still loaded on every page, on purpose. Scripts can be added late, while the page is being built, and still work. A stylesheet added that late ends up at the bottom of the page, so the filter would briefly show unstyled before jumping into place. The CSS is small, so loading it everywhere is the better trade-off.
- NOTE: If you build your own filter form without the module, shortcode, action or widget, enqueue the
beautiful-taxonomy-filtersscript handle yourself to get select2 and the conditional dropdowns. - DOCS: The filter and action reference has moved to the developer documentation. It was too long for the wordpress.org plugin page, which cut it off.
2.6.0
- BUGFIX: A post type whose name contains a hyphen, like wp-book, is now resolved correctly from its archive template. Previously only the part before the first hyphen was used, which meant the filter module silently didn’t appear and PHP threw a notice.
- BUGFIX: The filter module now resolves the post type archive slug the same way the rewrite rules and the filtered URL do. This fixes a PHP warning on post types registered with
'rewrite' => falseand a mismatched URL on post types whosehas_archivediffers from their rewrite slug. - BUGFIX: A taxonomy registered without an explicit all_items label no longer shows its own name as the “all” value. WordPress silently falls all_items back to the taxonomy name, so the filter info module printed things like “Meal Types: Meal Types” and the dropdowns had an “all” option reading just “Meal Types”. You’ll now get “All Meal Types” unless you’ve set the label yourself, in which case nothing changes.
- BUGFIX: The select2 placeholder attribute is now properly escaped. A placeholder containing a quote, whether it came from a taxonomy label or from your own
beautiful_filters_dropdown_placeholdercallback, could break the markup of the dropdown. - IMPROVEMENT: The redirect to the filtered URL now goes through
wp_safe_redirect(). The URL the plugin builds always points at your own site, so nothing changes for anyone, but if you use thebeautiful_filters_new_urlfilter to send visitors to another domain you’ll need to add that host to WordPress’allowed_redirect_hostsfilter. Polylang already registers its language domains there, so a domain per language setup is unaffected. - BUGFIX: The conditional dropdowns AJAX endpoint no longer builds a malformed query when none of the post type’s taxonomies have any terms, and no longer emits PHP warnings when called without parameters.
- NEW FILTER:
beautiful_filters_post_type_archive_sluglets you change the post type archive segment of a filtered URL, the counterpart tobeautiful_filters_taxonomy_rewrite_slug. Thanks to AsfalothDE who first asked for this back in 2017. - NEW FILTER:
beautiful_filters_taxonomy_all_items_labellets you set the “all terms” string yourself, and is the way to get the old behaviour back if you preferred it. See the developer documentation. - NEW FILTERS:
beautiful_filters_pre_related_termsandbeautiful_filters_related_terms_sqllet you replace or modify the conditional dropdowns database query, so you can point it at your own index on a large site.
2.5.0
- BUGFIX: The post type slug is no longer added twice to the filtered URL when a taxonomy is registered with a rewrite slug nested under the post type archive, like the rewrite slug
horses/locationson a post type archived athorses. You’ll get /horses/locations/spain/ instead of /horses/horses/locations/spain/ from now on. The old URLs are still registered as rewrite rules so anything you’ve already linked to keeps working. - NOTE: If you’ve been working around this with your own code you can remove it now. A
beautiful_filters_new_urlfilter that strips the repeated slug does no harm but isn’t needed anymore. Anything doing a plain str_replace on the post type slug will break the URL instead of fixing it, so do get rid of that one. - BUGFIX: A taxonomy registered without a rewrite slug, but with a query_var different from the taxonomy name, produced a URL that didn’t match the rewrite rules and gave a 404. Both are built from the same value now.
- BUGFIX: Polylangs language prefixed rewrite rules haven’t actually been generated since 2.4.0, so filtered URLs like /en/horses/locations/spain/ gave a 404. They’re back.
- NEW FILTER:
beautiful_filters_taxonomy_rewrite_sluglets you decide what URL segment a taxonomy gets. See the developer documentation.
2.4.9
- BUGFIX: The
[show_beautiful_filters]and[show_beautiful_filters_info]shortcodes now render at the position of the shortcode instead of above the content. If you previously relied on the old placement you may need to move the shortcode or adjust your styling. - IMPROVEMENT: Hardened the filter modules against a rare PHP 8 fatal error when a custom
beautiful_filters_post_typesfilter returns a non-array value. - IMPROVEMENT: The conditional dropdowns AJAX endpoint now returns a proper JSON error response on a failed security check.
2.4.8
- IMPROVEMENT: Tested up to WordPress 7.1.
- BUGFIX: Fixed a PHP 8+ fatal error that could occur on archive pages when an array-style query parameter was present in the URL. Also hardened a couple of related PHP 8 notices.
2.4.7
- BUGFIX: Sorted a security issue. Please make sure you update to this version or later.
2.4.6
- BUGFIX: Fixed issue where the allowed post types option value
beautiful_taxonomy_filters_post_typescould be something other than an array and caused fatal errors.
2.4.5
- BUGFIX: Fixes some issues with Select2. without search it will fail to stay open for no apparent reason so search is always enabled.
- BUGFIX: Fixed so that select2 honours changed quantities from the select options.
- IMPROVEMENT: Select2 now does not destroy and recreate the dropdowns all the time, instead we force it to recognise a change event.
- IMPROVEMENT: Latest select2 library in use.
2.4.4
- BUGFIX: Sorted the recent security issue. Please make sure you update to this version or later.
2.4.3
- BUGFIX: Fixed if statement causing PHP warning.
- IMPROVEMENT: Conditional dropdowns now attempts to not disable any value in the first dropdown being filtered, making it a bit more intuitive.
2.4.2
- BUGFIX: Missing slash in pagination rules. Thanks @fabianlindfors
2.4.1
- BUGFIX: Did not check if new rewrite rules was empty before attempting to merge them.
2.4.0
- This version should fix issues caused by last update
- IMPROVEMENT: Complete rewrite of the rewrite rules (huehuehue). note: BTF no longer allows for any order of taxonomies in URL. Only the order in which they are registered.
- BUGFIX: Fixed some warning when no taxonomies we’re registered on startup.
2.3.5
- FEATURE: Added shortcode for filter module. Use
[show_beautiful_filters post_type="yourcptslug"]where you want! - BUGFIX: Fixed issue where API function is_btf_filtered() returned false if query_var is different than registered taxonomy slug.
- BUGFIX: Some bugfixes for non existing contents etc. Just be happy with the shortcodes and carry on with your day!
2.3.4
- BUGFIX: HTML characters now properly decode when using conditional dropdowns.
- BUGFIX: Fixed Polylang urls incorrect when using homepage slug in URL.
- BUGFIX: Countable warning in post count for terms.
- BUGFIX: Fixed issue where has_archive was not honored.
2.3.3
- BUGFIX: Made a booboo with the previous versions new improved dropdown query. Please update right away and don’t try to find me.
2.3.2
- IMPROVEMENT: Vastly improved the conditional dropdowns query. It should now work even with pretty large sets of posts and terms.
- IMPROVEMENT: Norwegian translation added. Thank you Ørjan Hoyd H Vøllestad.
- BUGFIX: Widget now uses correct label for dropdown placeholders/labels.
- BUGFIX: Added initial slash to pagination in urls. Thanks @frantorres.
- BUGFIX: A pesky little php warning.
- BUGFIX: Some other stuff I can barely remember..
2.3.1
- BUGFIX: in_array warning on new installs. Move along, nothing to see here.
2.3.0
- IMPROVEMENT: New API functions are now available. They can be found in /includes/api.php. Most usable is probably
is_btf_filtered()which will return true or false if the current page is filtered by BTF. Not currently in use everywhere in the code tho so don’t peak.. - IMPROVEMENT: “Clear all” only appear if there are actually something to clear.. Courtesy of the new api.
- IMPROVEMENT: Body classes are now added if on a BTF enabled archive and if there is currently a filter active.
btf-archiveandbtf-filteredare added to the body class. Use these however you want! - BUGFIX: Don’t mess with the “all option” when conditional dropdowns are active without select2.
2.2.1
-
FEATURE: Disable fuzzy search in select2. It’s as easy as adding this filter:
function disable_fuzzy_search( $boolean ) {
return true;}
add_filter(‘beautiful_filters_disable_fuzzy’, ‘disable_fuzzy_search’, 10, 1);
(Thanks to babouz44 for the help).
- BUGFIX: Was a little quick on the RTL. now it will work as it should 🙂
2.2.0
- BUGFIX: You can now have a different taxonomy rewrite slug than it’s query_var and it’ll work just fine anyway. Adds better compatibility with plugins that registers their own taxonomies. Big thanks to Kristoffer Lorentsen. Have a cookie 🍪
- BUGFIX: Found a bug when conditional dropdowns was used without select2. Don’t ask.
-
IMPROVEMENT: Select2 will now automatically detect RTL languages. You can also set this manually using the filter:
function modify_rtl( $rtl ) {
return true;
}
add_filter( ‘beautiful_filters_rtl’, ‘modify_rtl’ ); -
IMPROVEMENT: Select2 will now automatically detect current language (if using Polylang or WPML) and apply the correct translation file. You can also set this manually yourself using the new filter:
function modify_current_language( $language ) {
return ‘sv’;
}
add_filter( ‘beautiful_filters_language’, ‘modify_current_language’ ); -
IMPROVEMENT: Some overall improvement to the select2 JS script. Just a bit of refactoring.
2.1.1
- IMPROVEMENT: Added Portuguese Brasil translation (Thanks to Bruno Sousa).
- IMPROVEMENT: Added Romanian translation (Thanks to Roberto Tamas).
2.1.0
- IMPROVEMENT: The conditional dropdowns now also apply when loading a filter result page. Please post all issues to the support forums.
- IMPROVEMENT: Updated POT file.
- IMPROVEMENT: Updated Swedish translation.
- IMPROVEMENT: Added Bulgarian translation (Thanks to Georgi Marokov).
2.0.0
- FEATURE: It’s finally here! AJAX-powered conditional dropdowns. Select a term in one taxonomy and see the selectable terms change in all other taxonomies. No more “no posts found” results for the visitors. This is a BETA feature which you have to enable in the advanced settings. If you find issues please create a topic in the forums.
A loader will appear and the dropdowns will be disabled while the AJAX works its magic if it takes longer than 800ms. any new AJAX triggered before the previous has finished will also abort the previous one.
You can replace the default loader .gif (WordPress spinner) using the new filter:
function my_custom_loader( $loader, $taxonomy, $posttype ){
return $loader; // $loader is an img tag
}
add_filter('beautiful_filters_loader', 'my_custom_loader', 10, 3);
- FEATURE: A new style option “Simple” which just arranges everything without adding colors, drop shadows etc. also tweaked other styles for new select2 classes.
- IMPROVEMENT: Select2: Now a wrapping span element is always added to the results of the dropdown which carries over all classnames from the original option element. Use this to style hierarchical taxonomies.
.select2-results__option .level-1{ padding-left: 1em; }. - IMPROVEMENT: Added Portuguese (Thanks to Luis Martins).
- IMPROVEMENT: Added Catalan (Thanks to Maiol Xercavins).
- IMPROVEMENT: Added Swiss (Thanks to Raphael Hüni).
- IMPROVEMENT: Fixed some untranslatable strings.
- IMPROVEMENT: Updated POT file and Swedish translation.
- IMPROVEMENT: Greatly improved the information on the help and about tabs. Now there’s links to the forum, FAQ, hooks and github repo. All to make it easier for you to nag at me!
- IMPROVEMENT: Updated screenshots for wordpress.org
- IMPROVEMENT: Added a very basic stylesheet always included (already minimized to 486b) with BTF.
1.3.0
Just a minor update right now.. bigger things to come. carry on!
- IMPROVEMENT: Updated select2 lib to v 4.0.3. Hopefully fixing some issues with later versions of Safari on IOS
1.2.9
- BUGFIX: Fixed undefined index for widget walker.
- BUGFIX: Fixed incorrect post count in each term when filter module is not on a CPT archive.
- IMPROVEMENT: Updated german translations. Thanks to Nils Schönwald.
- IMPROVEMENT/BUGFIX: Updated select2 library to 4.0.1 (latest stable). This seems to fix issue of
.changeevent not happening on original select element. - IMPROVEMENT: Fixed some commenting inconsistencies. Nothing to see here folks.
1.2.8
IMPORTANT: In this update we’ve done a big overhaul of the settings page. This was important to be able to keep improving BTF settings and features. Unfortunately this means that any of your advanced settings will have to be reset. After updating please take a look at the “Advanced options” tab to make sure everything is set as you want.
- FEATURE: Added option under Advanced tab to show term description in the dropdowns. If you’re also using select2 the description will wrap in a span which you can style however you like! This feature is also available for widgets and of course you can modify it by post type using the new filter “beautiful_filters_show_description” which you can read more about in Notes on wordpress.org
- IMPROVEMENT/BUGFIX: Makes sure that when the option to show number of posts in term it will only show the number of posts for the current post type (if multiple post types shares the same taxonomies). Pretty neat!
- IMPROVEMENT: Complete overhaul of the settings page. Now with tabs and more logical separation of settings. It will allow me to add more settings to the advanced tab without overwhelming the user.
- IMPROVEMENT: Added notification and checks of versions to make setting changes easier in the future. Will be able to automatically convert settings so you’ll no longer lose them. Sorry about that btw..
- IMPROVEMENT: Added a notification on activat
Follow this listing's changes (Atom feed)