Problem with Custom Taxonomy Filters

Forums › Forums › Search & Filter Pro › Problem with Custom Taxonomy Filters

Viewing 10 posts – 1 through 10 (of 10 total)
  • Anonymous
    #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 ul

    Do you guys have an idea of what could be causing this issue ?
    Best Regards,
    Damien

    Ross Moderator
    #19046

    Hi 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

    Anonymous
    #19053

    Hi Ross,

    The all categories is blank for the “Sort Order” dropdown list, but this one works as expected.
    The all_items_label for custom category is setting to “All”
    If I add a “Test” heading, there is the html output :
    OUTPUT

    Ross Moderator
    #19054

    Hi 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
    #19063

    Ok 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

    UI FORM SETTINGS

    but the ul is still empty 🙁

    Ross Moderator
    #19066

    Hi 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
    #19068

    my 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
    #19069

    Just 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
    #19090

    Hi 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

    Anonymous
    #19092

    Yes, I was using the 1.4.1 version,
    Works with 1.4.3 !
    Thanks for your help Ross !!!

Viewing 10 posts – 1 through 10 (of 10 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.