Guest User

Untitled

a guest
May 13th, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. function sort_posts_alphabetically_by_title($query) {
  2. if ($query->is_category() && $query->is_main_query()) {
  3. $query->set('orderby', 'title');
  4. $query->set('order', 'ASC');
  5. }
  6. }
  7. add_action('pre_get_posts', 'sort_posts_alphabetically_by_title');
Advertisement
Add Comment
Please, Sign In to add comment