Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
<?php
/**
* Plugin Name: Remove orderby when counting comments.
*/
namespace PWCC\Test58368;
/**
* Remove orderby when counting comments.
*
* @param string[] $clauses An associative array of comment query clauses.
* @param WP_Comment_Query $query Current instance of WP_Comment_Query (passed by reference).
* @return string[] Modified $clauses.
*/
function no_comment_count_order_by( $clauses, $wp_comment_query ) {
if ( ! $wp_comment_query->query_vars['count'] ) {
return $clauses;
}
$clauses['orderby'] = '';
return $clauses;
}
add_filter( 'comments_clauses', __NAMESPACE__ . '\\no_comment_count_order_by', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment