Change the sequence of numbers

Home Forums Calendar Products Filter Bar Change the sequence of numbers

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1230412
    Florian
    Participant

    What I’ve done:
    – I created a new “additional field” “Alter” (= “age”) with numbers which can be selected in the backend
    – I added the additional field to the filter-bar


    What the filter-bar does:

    The sequence of the numbers is not what I want:

    What it Should be:
    The numbers should be in this order:
    -8
    -9
    -10
    -11
    – (…)

    Is it possible to change the order of the numbers?

    #1230880
    Nico
    Member

    Hi there Florian,

    Thanks for getting in touch with us! I can help you on this πŸ™‚

    Can you please try the suggested solution in this previous reply β†’ https://theeventscalendar.com/support/forums/topic/filterbar-checkbox-order/#dl_post-1099120 ?

    You’ll need to change the field key for the correct one in the site. If you are not sure of what this value should be just sent me a URL where I can see the filter in action.

    Hope that helps,
    Best,
    Nico

    #1233694
    Florian
    Participant

    Thx Nico, it’s working now.

    Steps I’ve done

    1. I’ve put this code in the theme’s “functions.php”:

    /*
     * The Events Calendar - Change filter values order
    */
    add_filter( 'tribe_events_filter_values', 'tribe_re_order_filter_tags', 10, 2 );
    function tribe_re_order_filter_tags ( $values , $slug ){
    	
    	if ( $slug == '_ecp_custom_2' ) {
    		sort($values); // a-z
    	}
    	
    	return $values;
    }

    2. To figure out what to fill in for “_ecp_custom_2” (field key):
    Events >> Help >> @ Systeminformation I found the snippet:

    [10] => Array
            (
                [name] => _ecp_custom_10
                [label] => Alter
                [type] => checkbox
                [values] =>  5

    => _ecp_custom_10 is the neccesary field key (in my case)

    Just for (my) interest:

    http://php.net/manual/en/array.sorting.php <– are these the options to sort the values of the custom field?

    #1233736
    Nico
    Member

    Thanks for following up Florian! Nice work checking the field id in the system information πŸ™‚

    http://php.net/manual/en/array.sorting.php <– are these the options to sort the values of the custom field?

    Yeah, those are all PHP functions that might help you ordering the values.

    I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Change the sequence of numbers’ is closed to new replies.