The picture gives an illustration of the pending comments I am referring to. As you can see, the number shown on the menu bar is different from the number shown on the pending column.
I am trying to find a way to edit the numbers highlighted in yellow
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can manually adjust this number using the following method.
function adjust_wp_comments_count( $original_counts ) {
$counts = new stdClass();
$counts->moderated = 99;
return $counts;
}
add_filter( 'wp_count_comments', 'adjust_wp_comments_count', 100, 1 );
The line: $counts->moderated = 99 is what you will need to adjust if you want to set it to a particular value or calculation of your choosing.
Note: I’ve set the filter priority to 100 as I found other plugins also affect this. It depends on your setup. If you add this filter and it doesn’t work, change 100 to 100000 or any other large number. The higher the number, the more likely that your modifications will take effect.
WordPress also dynamically changes the comment counts on-the-fly as you change comment status in the Edit Comments page. This code doesn’t take any of that into consideration. It simply provides you a mechanism to set the number as it’s displayed when the page loads.
Note: Forcefully setting this value may have unintended consequences elsewhere in the system. Test and evaluate for your particular circumstances.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0
