How to Query Show Posts by Most Comments in WordPress -
This Function can be a custom filter in Elementor or whatever post archive you are using
Side Note:
In Elementor you can add the custom filter id "popular_filter" to the custom filter section in the query area of the posts widget.
/*Popular Post Query by Comments -Start */
// Showing posts ordered by comment count in Posts Widget
add_action( 'elementor/query/popular_filter', function( $query ) {
// Here we set the query to fetch posts with
// ordered by comments count
$query->set( 'orderby', 'comment_count' );
} );
/*Popular Post Query by Comments - End */
Sincerely,
Sir, Doogie Howser