Support » Fixing WordPress » HOW TO TURN FUNCTION OFF AND ON

  • I would like to turn a php function on and off, I’ve placed this code on my index.php

    function default_sort_ascend($t) {
         $q = $t->query_vars;
         if ( empty($q['order']) || ((strtoupper($q['order']) != 'DESC') && (strtoupper($q['order']) != 'ASC')) )
              $q['order'] = 'ASC';
         $t->query_vars = $q;
     add_action('pre_get_posts', 'default_sort_ascend');

    How to create a button to switch back and forth from ‘DESC’ to ‘ASC’?

    The code above is great because it affects not only the home page but also the archives, etc…

    Thank you

  • The topic ‘HOW TO TURN FUNCTION OFF AND ON’ is closed to new replies.