Justin Young Profile Picture 2020 - PulseNest™
I hope you like what you see. If you need business management help from our team, get in touch.

How to Query Show Posts by Most Comments in WordPress

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

Was this post helpful?

Want to Offer Better Service?

Hi, Im Justin Young, the Founder of PulseNest. For years I struggled trying to balance sales, and customers while trying to provide the best service possible.

Justin Young Profile Picture 2020 - PulseNest™

About Justin Young

He is the founder of Spear Group. A coalition of marketing, SAAS, and business management systems. He has been recognized by businesses and associates for his business savvy and vision over the course of his career. Also he has some pretty sweet dance moves.

Want to Offer Better Service?

Hi, Im Justin Young, the Founder of PulseNest. For years I struggled trying to balance sales, and customers while trying to provide the best service possible.

Learn How PulseNest™ CRM Automation Can Help your Business