Change post order by category programmatically
-
Hi all,
I’m really sorry to post here this question but on the main WordPress forum I haven’t got any answer.Well, my need is to have the posts of some categories ordered by title and other by post date; I’ve created a child theme where the functions.php already contains this script for ordering by title:
/* Function for changing post order */ function modify_query_order( $query ) { $query->set( 'orderby', 'title' ); $query->set( 'order', 'ASC' ); } add_action( 'pre_get_posts', 'modify_query_order' );
How would you recommend me to modify this function? Do you have a more clever advice for hacking the post order making it “sensible” to the category where the query is being executed?
Thank you in advance,
Nicola
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Change post order by category programmatically’ is closed to new replies.