Can we redefin the function of the flame wordpress?



  • Hello, everyone. There's a website on wordpress and a plaguine of owl-carousel in constructions that can alter the location of the elements by name and date, but the problem is that it's only one way of sorting at a date: the old feathers and the younger elements are added at the very end of the slider. This is the function responsible for classifying elements

     function owl_function($atts, $content = null) {
     $args = array(
        'post_type' => 'owl-carousel',
        'orderby' => get_option('owl_carousel_orderby', 'post_date'),
        'order' => 'asc',
        'tax_query' => array(
            array(
                'taxonomy' => 'Carousel',
                'field' => 'slug',
                'terms' => $atts['category']
            )
        ),
        'nopaging' => true
    );
    }
    

    Can this function be redefined in the file with the only change 'order' => 'asc''order' => 'desc'so that the flame can be further updated and that the function is not redefined again?



  • Cross action https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts if $query->query_vars['post_type'] == 'owl-carousel' - that's your request. $query->query_vars['order'] You're welcome.

    function owl_order_change($query) {
        if ($query->query_vars['post_type'] == 'owl-carousel') {
            $query->query_vars['order'] = 'DESC';
        }
    }
    add_action('pre_get_posts', 'owl_order_change');
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2