
Taxonomy Chain Menu
4,95$
Taxonomy Chain Menu – is WordPress plugin with one shortcode only which allows to create chain menus with any type of taxonomies.
Taxonomy Chain Menu – is WordPress plugin with one shortcode, which allows to create taxonomies terms chain menus with any inbuilt and custom types of WordPress taxonomies.
Taxonomies terms should be created in hierarchy:
Shortcode example: [taxonomy_chain_menu post_type='product' taxonomy='product_cat' parent_id=0 exclude='36,12' watch_view='posts' show_count=1 button_title='Watch It' target='_blank' label_taxonomy='Producer|Model' label_post='Select car' chain_id='chain1' connect_table='ttt1']
Demo page 1 Demo Ready Chain Compatible with TABLEON Compatible with WOOT Compatible with WOOF filtration behavior Questions?
Shortcode attributes:
- post_type – what post type to use in the chain menu. Default type is 'post'.
- taxonomy – what taxonomy terms to navigate. Default taxonomy is 'category'.
- parent_id – started term ID, 0 means top parents. Default slug is 0.
- exclude – terms ids to hide from the chain. For example: 12,44,73.
- include – terms ids to show. Opposite to 'exclude'. For example: 11,43,72.
- include_top – terms ids related to the top parent terms only (parent == 0). For example: 10,42,71.
- show_count – show/hide count of posts in the terms in drop-downs options. Default value is 0.
- target – (premium version) how to open selected post/terms page. Default is: '_self' (opening in the same browser tab). To open in another tab use: '_blank'
- watch_view – values: 'posts', 'terms', 'none'. What to show on the end of the chain. Posts - drop-down with posts. Terms - button with the link to posts of the selected term in the last drop-down. None - nothing, good to apply with products tables filtering.
- label_taxonomy - label(s) of the drop-down(s). Example: Producer|Model (premium version only can use divider for drop-downs labels | - allows to set individual title for each drop-down). Also it is possible to use custom actions (must started from 'call_filter_') for translations, example: [taxonomy_chain_menu label_taxonomy='call_filter_chain1' label_post='call_filter_chain1-post']. In file functions.php add next code:1234567891011121314151617add_filter('chain1', function($args) {$res = 'Producer|Model';//divider is in premium version only//for WPML compatibility as an exampleif (defined('ICL_LANGUAGE_CODE')) {switch (ICL_LANGUAGE_CODE) {case 'es':$res = 'Productor|Modelo';//divider is in premium version onlybreak;case 'uk':$res = 'Виробник|Модель';//divider is in premium version onlybreak;}}return $res;}, 10, 1);
Demo: https://cars.wp-filter.com/simple-taxonomy-chain-menu/ - Country|City|District - label_post - label of the posts drop-down. To use action instead of text in file functions.php add next code: (must started from 'call_filter_')1234567891011121314151617181920add_filter('chain1-post', function($args) {$res = 'Select car';//for WPML compatibility as an exampleif (defined('ICL_LANGUAGE_CODE')) {switch (ICL_LANGUAGE_CODE) {case 'es':$res = 'Seleccionar coche';break;case 'uk':$res = 'Яке твое авто';break;default:$res = 'Select your car';break;}}return $res;}, 10, 1);
- button_title – title of the button at the end of the chain. By default it is 'GO!'. Also is possible to use action (must started from 'call_filter_'), example: [taxonomy_chain_menu post_slug='product' taxonomy='product_cat' button_title='call_filter_chain1-btn']1234567891011121314151617add_filter('chain1-btn', function($args) {$res = 'Take it!';if (defined('ICL_LANGUAGE_CODE')) {switch (ICL_LANGUAGE_CODE) {case 'es':$res = 'Tomar lo!';break;case 'uk':$res = 'Забираймо!';break;}}return $res;}, 10, 1);
- label_before - (premium version) any words before first drop-down (v.2.0.7.2). Also possible to set text through action (must started from 'call_filter_'): ([taxonomy_chain_menu post_slug='product' taxonomy='product_cat' label_before='call_filter_chain1-before'])1234567891011121314151617add_filter('chain1-before', function($args) {$res = 'Take our best products: ';if (defined('ICL_LANGUAGE_CODE')) {switch (ICL_LANGUAGE_CODE) {case 'es':$res = 'Toma nuestros mejores productos: ';break;case 'uk':$res = 'Візьміть наші найкращі продукти: ';break;}}return $res;}, 10, 1);
Demo: https://demo.products-tables.com/taxonomy-chain-menu/
- ready_chain -Â (premium version)Â allows to display pre-selected values in the chain menu, example: [taxonomy_chain_menu watch_view='posts' ready_chain='17,20,post(51)'] - at the end of the chain will be displayed drop-down with posts and button with the link to the selected post. If exists more sub-categories use 0 (zero) at the end: [taxonomy_chain_menu ready_chain='17,20,0']. Example: https://woocommerce.wp-filter.com/simple-taxonomy-chain-menu-2/
- chain_id - (for developers) unique JavaScript identifier for js event 'taxonomy-chain-menu' and in custom WordPress actions
- connect_table - unique identifier of posts/products table set in table shortcode attribute or its backend settings. It is possible to use Taxonomy Chain Menu as filter with posts and products table plugins: TABLEON - WordPress Posts Table Filterable https://posts-table.com/ and WOOT - WooCommerce Products Table https://products-tables.com/
Such scripts cooperation is possible thanks to JavaScript event 'taxonomy-chain-menu' and shortcode attributes 'chain_id' with attribute 'connect_table' - do_filter - accepts from the box only one value - 'woof' (demo: https://demo.products-filter.com/taxonomy-chain-menu ), but it is possible to adapt any another wordpress/woocommerce filter plugin (for developers) using js event taxonomy-chain-menu-do-filter and values there: e.detail.term_id, e.detail.slug, e.detail.container. Example: [taxonomy_chain_menu post_slug='product' taxonomy='product_cat' do_filter='woof']
- select_wrapper -Â Â (premium version)Â (from 2.0.8) has only one value 'selectron23' and allows to wrap drop-down in reach html-element Selectron23:
See example page. Use with attribute 'chain_id' to separate functionality for different chain menus. Use hook 'taxonomy-chain-menu-option-data' to set all the data. See code example (add to file functions.php) below to set data in Selectron23 drop-down:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354add_filter('taxonomy-chain-menu-option-data', function($id, $taxonomy, $parent_id, $chain_id) {$data = [];$get_thumbnail = function ($thumbnail_id, $size = 'thumbnail') {$img = wp_get_attachment_image_src($thumbnail_id, $size);if (!isset($img[0])) {$img = wp_get_attachment_url($thumbnail_id);} else {$img = $img[0];}return $img;};//+++if ($chain_id === 'chain1') {if ($taxonomy === 'product_cat') {$term_id = $id;if ($term_id > 0) {$data['text'] = strip_tags(tag_description($term_id));$thumbnail_id = get_term_meta($term_id, 'thumbnail_id', true);$data['img'] = $get_thumbnail($thumbnail_id);} else {//labels$deep = 0;if ($parent_id > 0) {$deep = count(get_ancestors($parent_id, $taxonomy)) + 1;}switch ($deep) {case 0:$data['text'] = 'Best producers';$data['img'] = $get_thumbnail(31);break;case 1:$data['text'] = 'Best models';$data['img'] = $get_thumbnail(32);break;case 2:$data['text'] = 'Best sub-models';$data['img'] = $get_thumbnail(30);break;}}}if ($taxonomy === 'is_post') {$post_id = $id;$data['text'] = 'Any short text about post here';$data['img'] = $get_thumbnail(get_post_thumbnail_id($post_id)); //featured image}}return $data;}, 10, 4); - select_width - (from 2.0.8) widths for drop-downs in chain. Use one value or some separated by '|'. Examples: '300px', '300px|250px|20%'. Last value is actual for drop-downs in chain with number 3 and more.
- max_posts_count - (from 2.0.8) set maximum count of posts in posts drop-down
- posts_orderby - (from 2.0.8) how to order posts in posts drop-down (by title, id, meta). By default: title.
- posts_order - (from 2.0.8) posts order direction in posts drop-down. Possible values: ASC, DESC
- posts_order_meta_key - (from 2.0.8) here is meta key by which posts in posts drop-down should be ordered. Be care - meta values should exist in the requested posts. Example: [taxonomy_chain_menu post_slug='product' taxonomy='product_cat' posts_orderby='meta_value_num' posts_order_meta_key='prod_1' posts_order='DESC']
- selectron23_max_open_height - (from 2.0.8) works if wrapper Selectron23 is applied. Defines maximum drop-down height in pixels if opened. If drop-down is larger - vertical scroll appears. In px only. Value example: '150|200|300' - width for first, second and third drop-down. If more than 3 drop-downs will be applied last value, in this case '300'.
[no jQuery - pure JavaScript!]
Hooks:
- taxonomy-chain-menu-option-data - for data set when selectron23 applied, see full code example above.1234567add_filter('taxonomy-chain-menu-option-data', function($id, $taxonomy, $parent_id, $chain_id) {$data = [];//actions herereturn $data;}, 10, 4);
- taxonomy-chain-menu-loader - to change loader image
- taxonomy-chain-menu-do-filter - javascript hook, for developers only hook for synchronizing filter plugins. In code called as:1$.dispatchEvent(new CustomEvent('taxonomy-chain-menu-do-filter', {detail: {term_id, slug, container}}));
- taxonomy-chain-menu-select-changed - javascript hook, works when user did selection in a drop-down of the chain
Included as gift into the next plugins bundle:
Compatible with WPML automatically, no actions needed.
Demo page 1 Demo Ready Chain Compatible with TABLEON Compatible with WOOT Compatible with WOOF filtration behavior Questions?
