I want to develop a plugin that adds one or more metadata terms to the comments. I can do this by using the add_comment_meta function, and I can display it in the edit-comments.php page by using the comment_status_links and pre_get_comments hooks. The process I followed is similar to the one detailed here:


To clarify, at the top it now shows, for example:

All | Pending (10) | Approved (100) | Spam (0) | Trash (0) | MY METADATA (5)

Now, my issue is with the Ajax update of the comments count. For example, if a comment that is approved is then marked as spam, the number of approved comments, 100, is updated automatically to 99, and the number of spam comments increases from 0 to 1. However, the number of My Metadata does not change, and remains at 5 until I refresh the page; then, it updates to 4, which is what I want.

How can I include my metadata feature in the Ajax update, so the user does not need to refresh the page to see the correct number? I think I need to use a script similar to wp-admin/js/edit-comments.js, but would rather avoid using a whole different Ajax call, which would place somewhat redundant code there given the complex logic used already in the edit-comments.js script.

Any feedback is appreciated! Thanks your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.