Forums › Forums › Search & Filter Pro › Problem with Custom Taxonomy Filters
Tagged: custom taxonomy, empty, filters, terms
- This topic has 9 replies, 2 voices, and was last updated 9 years, 5 months ago by Anonymous.
-
Anonymous(Private) June 8, 2015 at 10:29 am #19030
Hi guys,
I don’t know why but my custom category doesn’t display in front end page.This is my code in order to add my custom post type + taxonomy
add_action('init', 'create_value'); function create_value() { $labels = array( 'name' => _x('Value', 'value'), 'singular_name' => _x('Value', 'value'), 'add_new' => _x('Add', 'value'), 'add_new_item' => __('Add new value'), 'edit_item' => __('Edit value'), 'new_item' => __('New value'), 'view_item' => __('Go to value'), 'search_items' => __('Search an value'), 'not_found' => __('No value'), 'not_found_in_trash' => __('No value in trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'menu_icon' => 'dashicons-lightbulb', 'show_ui' => true, 'query_var' => true, 'has_archive' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => true, 'menu_position' => 1 ); register_post_type('value',$args); } register_taxonomy( "filter", array("value"), array("hierarchical" => true, "labels" => array('name'=>"Category",'add_new_item'=>"Add category"), "singular_label" => __( "Field" ) ) );
The following images shows how I’ve configured Search & Filter plugin, and the display result. You can see that the li.sf-field-taxonomy-filter is empty.
Category Settings
Display Settings
Terms
Front End Result
Empty ulDo you guys have an idea of what could be causing this issue ?
Best Regards,
DamienRoss Moderator(Private) June 8, 2015 at 12:36 pm #19046Hi Damien
I see you are not setting all the labels – if I remember correctly S&F looks at the
all_items_label
so it knows what to put first in the fields – ie “all categories” – try adding this and see if it works?Thanks
Ross Moderator(Private) June 8, 2015 at 1:19 pm #19054Hi Damien
But did you try to add the correct labels for the taxonomy above?
register_taxonomy( "filter", array("value"), array("hierarchical" => true, "labels" => array('name'=>"Category",'add_new_item'=>"Add category"), "singular_label" => __( "Field" ) ) );
You should be setting way more labels than just “name” and “add new item”
Thanks
Anonymous(Private) June 8, 2015 at 1:57 pm #19063Ok I replace with this
// hook into the init action and call create_value_cat when it fires add_action( 'init', 'create_value_cat', 0 ); // create two taxonomies, genres and writers for the post type "book" function create_value_cat() { // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' => _x( 'Type', 'taxonomy general name' ), 'singular_name' => _x( 'Type', 'taxonomy singular name' ), 'search_items' => __( 'Search Type' ), 'all_items' => __( 'All Type' ), 'parent_item' => __( 'Parent Type' ), 'parent_item_colon' => __( 'Parent Type:' ), 'edit_item' => __( 'Edit Type' ), 'update_item' => __( 'Update Type' ), 'add_new_item' => __( 'Add New Type' ), 'new_item_name' => __( 'New Type Name' ), 'menu_name' => __( 'Type' ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'type' ), ); register_taxonomy( 'filter', array( 'value' ), $args ); }
S&F Search UI form is configured like this
but the ul is still empty 🙁
Ross Moderator(Private) June 8, 2015 at 2:29 pm #19066Hi Damien
At this point I’m not sure what to suggest
Perhaps your
add_action( 'init', 'create_value_cat', 0 );
call is being called within another hook and therefore being fired too late although you have put a high priority on it..You could also try using https://codex.wordpress.org/Template_Tags/wp_list_categories somewhere in one of your templates to see if this taxonomy is loaded correctly.
If
wp_list_categories
is not working correctly then you are not initialising your taxonomy correctly.Thanks
Anonymous(Private) June 8, 2015 at 2:39 pm #19068my list categories output is working, and i’m not sure that this issue is due to
add_action( 'init', 'create_value_cat', 0 );
because before I do not use it.
WEIRD :((Anonymous(Private) June 8, 2015 at 2:53 pm #19069Just a note.
I just compared this website with an older one that i’ve made, with S&F plugin that works properly.<script type='text/javascript' src='http://somfy.local/wp-content/plugins/search-filter-pro/public/assets/js/search-filter-build.js?ver=1.4.1'></script> <script type='text/javascript' src='http://somfy.local/wp-content/plugins/search-filter-pro/public/assets/js/chosen.jquery.min.js?ver=1.4.1'></script>
On my actual website, I can see the plugin loads 2 js files
On my older website, the plugin don’t load the 2 files, the problem can be cause by this ?Ross Moderator(Private) June 8, 2015 at 5:19 pm #19090Hi Damien
Just thought (and think I have the answer) – what version of the plugin are you using? The current version is 1.4.3 – this latest version has compatibility fixes for WordPress 4.2
Thanks
-
AuthorPosts