simranjeetz
Forum Replies Created
Viewing 4 replies - 1 through 4 (of 4 total)
-
Forum: Developing with WordPress
In reply to: Change category default order – comments descendingfunction my_pre_get_posts( $query ) { if ( is_category() ) $query->set( 'orderby', 'comment_count' ); return $query; }Now I need second conditional only
Forum: Developing with WordPress
In reply to: Change category default order – comments descendingused this and it worked.
function my_pre_get_posts( $query ) { $query->set( 'orderby', 'comment_count' ); return $query; }Please check if this is correct. Also please tell me how to add second conditional. Problem is that this also changed my admin area post order which i dont want. How to correct this?
Forum: Developing with WordPress
In reply to: Change category default order – comments descendingI used this
function set_post_order_in_admin( $wp_query ) { if ( $wp_query->is_main_query() ) { $wp_query->set( 'orderby', 'comment_count' ); $wp_query->set( 'order', 'DESC' ); } } add_filter('pre_get_posts', 'set_post_order_in_admin' );Code didnt work. I got latest posts on top. Not posts with max comments. Can you also suggest how to add second conditional. Also I want no changes in admin. Only front-end in category list. Thanks for this
- This reply was modified 8 years, 2 months ago by simranjeetz.
- This reply was modified 8 years, 2 months ago by simranjeetz.
Forum: Developing with WordPress
In reply to: Change category default order – comments descendingthanks a lot.
I have several posts. When I use this code and go to a category page, my posts are not shown in comments number descending order. This is therefore not working.
Viewing 4 replies - 1 through 4 (of 4 total)