Advertisement
phpface

Untitled

Jan 30th, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. if( ! function_exists( 'videotube_child_reorder_category_videos' ) ){
  2.     /**
  3.      *
  4.      * Reordering videos
  5.      *
  6.      * @link https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
  7.      *
  8.      * @param $query
  9.      *
  10.      */
  11.     function videotube_child_reorder_category_videos( $query ) {
  12.        
  13.         if( $query->is_main_query() && $query->is_tax( 'category' ) ){
  14.             $query->set( 'orderby', 'post_title' );
  15.             $query->set( 'order', 'ASC' );
  16.         }
  17.        
  18.     }
  19.     add_action( 'pre_get_posts' , 'videotube_child_reorder_category_videos', 10, 1 );
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement