fauzanjeg

Query Filter for Posts Pages and Search Pages

Jul 9th, 2021 (edited)
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.31 KB | None | 0 0
  1. /* Query Filter for Posts Pages and Search Pages */
  2. function query_filter_for_posts_search_pages( $query ) {
  3.     if ( is_front_page() || $query->is_search() ) {
  4.         $query->set( 'orderby', 'modified' );
  5.         $query->set( 'order', 'DESC' );
  6.     }
  7. }
  8. add_action( 'pre_get_posts', 'query_filter_for_posts_search_pages' );
Add Comment
Please, Sign In to add comment