How to limit comment author to one comment per post

This would depend on how your theme handles saving comments. For instance if it submits the form via ajax it will be expecting certain returns. The way I would hook into this would probably be through the pre_comment_approved filter. Checking the received email against any previously submitted posts then return unapproved if it fails. function … Read more

Log file reports SQL Error processing child comments

It looks like this is a bug related to caching in WordPress v4.6.1 which you can follow on Trac ticket #37696. A proper fix is scheduled for WordPress v4.6.2, but in the meantime, you could try the following workaround reported by Rarst, who created the issue on Trac: Issue goes away if I disable Object … Read more

How to Orderby Comments by post title?

The WP_Comment_Query class supports ordering by: ‘comment_agent’, ‘comment_approved’, ‘comment_author’, ‘comment_author_email’, ‘comment_author_IP’, ‘comment_author_url’, ‘comment_content’, ‘comment_date’, ‘comment_date_gmt’, ‘comment_ID’, ‘comment_karma’, ‘comment_parent’, ‘comment_post_ID’, ‘comment_type’, ‘user_id’, ‘comment__in’, ‘meta_value’, ‘meta_value_num’, There’s a way to adjust it via filters so we can support ordering by the post title: $args = [ ‘status’ => ‘approve’, ‘post_status’ => ‘publish’, ‘post_type’ => ‘post’, ‘orderby’ => … Read more

Get the top level comment ID

Wait? Did you just state get_comment_ancestors() does not exist? What were they thinking… We can do this by looping through the entire comment thread until we find the top level comment. We identify it by parent_comment being set to 0: /** * Return the top parent comment ID * * @param $comment_id * @return comment … Read more

How would I add the comment count to this sub-pages of current page snippet

A custom walker can be passed to wp_list_pages() using the $walker parameter. Here is a custom walker named WPSE_Walker_Page_Comment_Count() which is based on the default page walker, Walker_Page(). We’re only overriding the start_el() method in this case. The output has been customized to include the comment count. First, add the walker code to your theme’s … Read more