• Resolved webpressbg

    (@webpressbg)


    Hello Team,

    I am using the Book Your Travel theme and I am trying to create calendar that sorts tours by month, from January to December. I activated your plugin and in the backend everything is ok, but in the frontend it doesn’t work as i expected.

    I have in turn edited the file in the theme that is responsible for this as per your descriptions in the plugin docs, but there wasn’t result.

    function get_taxonomy_terms_array($taxonomy_type) {
                    $terms = get_terms( array(
                            'taxonomy' => $taxonomy_type,
                            'orderby' => 'term_order',
                            'order' => 'ASC',
                            'hide_empty' => 0
                    ) );

    Could you help me, please.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Marcel Pol

    (@mpol)

    Hello,

    The link is not to the website I guess?

    Some more general questions.
    What kind of thing is the month? Is January and September a taxonomy? And what is a tour, is that a post? In case there is confusion, this plugin only sorts terms. It will not sort posts based on term_order, because every post can have multiple terms.

    For that get_terms function, could you install the plugin Query Monitor and check if the query is being done with term_orderas well? Sometimes a theme or plugin hooks into it, or it uses a different query with a different hardcoded sort order.

    Is it possible to share the address of the website? Even privately sharing it would help. My email is [email protected] but please understand, communication is here on the public forum.

    Plugin Author Marcel Pol

    (@mpol)

    Hmm, annoying, that second widget seems to sort based on name or slug. I don’t understand why that would happen.

    Can you send me the zipfile of that theme? I would want to check the code and probably try it out in my testing environment. The widget that this is about is also part of the theme, right?

    Thread Starter webpressbg

    (@webpressbg)

    Hello,

    I resolved the problem with one simple modification of the above function:

    function get_taxonomy_terms_array($taxonomy_type) {
        $terms = get_terms(array(
            'taxonomy' => $taxonomy_type,
            'orderby' => 'slug',
            'order' => 'ASC',
            'hide_empty' => false,
        ));
    
        $key_label_array = array();
    
        foreach ($terms as $term) {
            $key_label_array[$term->slug] = $term->name;
        }
    
        return $key_label_array;
    }
    

    In this updated version of the function, the orderby argument is set to ‘slug’, which will sort the terms by the slug property in ascending order (as specified by the order argument). The sorting of the $key_label_array is no longer needed since the terms are already sorted by slug.

    Thank you for the support!!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sorting not working on the frontend’ is closed to new replies.