This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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