Custom Sort won’t work…
-
Hi there,
i try to custom-sort archives by title.
This snippet I found works so far:
add_action('pre_get_posts','sort_categories_by_title'); function sort_categories_by_title($x) { if(is_category()) { $x->query_vars['orderby'] = 'title'; $x->query_vars['order'] = 'ASC'; } }
when I try to restrict this to a special category, it won’t work:
add_action('pre_get_posts','sort_categories_by_title'); function sort_categories_by_title($x) { if(is_category(7)) { $x->query_vars['orderby'] = 'title'; $x->query_vars['order'] = 'ASC'; } }
The query(is_category(7)) seems to work, I placed an alert into this to check it.
But somehow, the custom-sorting won’t work anymore….
Thanks for your help.
- The topic ‘Custom Sort won’t work…’ is closed to new replies.