• Resolved GeekViseu

    (@geekviseu)


    Hi.

    First the plugin is very good.

    I’m testing it, but I find a little problem.

    When the listing is show and is category always shows the first category order by name, it should show the primary !!!

    Ex: Adding listing I chose “Tyres” as primary category and choose “Car Parts” and “Auto Repair” for example.

    In the field Categories on list shows: “Auto Repair +2”. It should show “Tyres +2”, because Tyres is primary category!!!

    Also in single view show the categories order by name… it should show the Primary and then the others.

    Now: Auto Repair Car Parts Tyres

    Should be: Tyres Auto Repair Car Parts

    Thank you for your time a if possible a solution!

    And

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Mahfuzul Alam

    (@mahfuz87)

    Hi

    Thank you for reaching out.

    This is possible to achieve this by overriding the template file. You can learn here how to override the template files – https://directorist.com/documentation/directorist/developers-guide/template-override/

    Please follow this gist to override the category filed on the single listing page – Directorist – Single page category sorting (github.com)

    Please let me know if you need further infomation.

    Kind Regards

    Thread Starter GeekViseu

    (@geekviseu)

    Hi. Thank you very much for your reply and effort but I thinking is a little confusion ??

    The categories were already in alphabetical order. What I said was that the primary category should be listed first and then the others in alphabetical order!!

    Please See this example:

    function get_post_primary_category($post_id, $term=’category’, $return_all_categories=false){
    $return = array();

    if (class_exists('WPSEO_Primary_Term')){
        // Show Primary category by Yoast if it is enabled & set
        $wpseo_primary_term = new WPSEO_Primary_Term( $term, $post_id );
        $primary_term = get_term($wpseo_primary_term->get_primary_term());
    
        if (!is_wp_error($primary_term)){
            $return['primary_category'] = $primary_term;
        }
    }
    
    if (empty($return['primary_category']) || $return_all_categories){
        $categories_list = get_the_terms($post_id, $term);
    
        if (empty($return['primary_category']) && !empty($categories_list)){
            $return['primary_category'] = $categories_list[0];  //get the first category
        }
        if ($return_all_categories){
            $return['all_categories'] = array();
    
            if (!empty($categories_list)){
                foreach($categories_list as &$category){
                    $return['all_categories'][] = $category->term_id;
                }
            }
        }
    }
    
    return $return;

    }

    Something like this !!!

    Thanks

    Personal note On line 61 of new category.php shouldn’t be: ‘las la-folder’ ???

    Plugin Support Mahfuzul Alam

    (@mahfuz87)

    Hi

    Thank you for your response.

    The custom code is working fine on our end. Categories are showing based on the parent > child pattern – https://prnt.sc/037pCSW3t0tg

    About icon: You can put any icon you want to show.

    If you still struggling with this issue please contact our support channel – https://prnt.sc/cKSW-z2RTXrs. We will try to help you on your live website.

    Please let me know if you need further information.

    Regards

    Thread Starter GeekViseu

    (@geekviseu)

    Hi. Thank you again.

    Yes I open a support ticket.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category order’ is closed to new replies.