Okay
  Public Ticket #2935923
Calendar dropdown list order
Closed

Comments

  •  10
    alleganps started the conversation

    How would I reorder the Calendar dropdown list as shown in the attached image? Preferably, I would like the list to sort alphabetically.

    Thank you, and have a great weekend.

  •  10
    alleganps replied

    I'm just following up on this post to see if there is a solution. Thank you for your help!

  •  785
    Zhivko replied

    Hi,

    Try following:

    Place the script below in your theme or child-theme functions.php file:

    // STEC MOD reorder calendars menu alphabetically
    add_action('wp_footer', function () {     if (false === wp_script_is('stec-js')) {
            return;
        }     ?>
        <script type="text/javascript">
            (function($) {             $(function() {                 $.stecExtend(function(m, events) {                     const $content = m.$instance.$top.find('.stec-top-menu-filter-by-calendar')
                            .find('li[data-calid]');                     $content.sort(function(a, b) {
                            const aTitle = $(a).find('span').text();
                            const bTitle = $(b).find('span').text();                         if (aTitle < bTitle) {
                                return -1;
                            }                         if (aTitle > bTitle) {
                                return 1;
                            }                         return 0;
                        });                     m.$instance.$top.find('.stec-select-all').after($content);                 }, 'onAddToEventsPool');             });
            })(window.jQuery);
        </script>
    <?php
    });



    Stachethemes Developer

  •  10
    alleganps replied

    Worked perfectly, as always. Thank you!