Disable comments on all posts/pages

The check if comments are enabled is performed by comments_open() function. You can make it always return false via a filter with something like this: add_filter(‘comments_open’, ‘__return_false’); Other way would be to make comments available to only registered users (that is if you don’t have open registration) in Settings > Discussion.

comment_post_ID 0 (cannot remove from dashboard)

I’m sorry can’t comment here but i’ll try to help. wp_handle_comment_submission function handing comments posting contains exact check for post_id: $post = get_post( $comment_post_ID ); if ( empty( $post->comment_status ) ) { … return error_happened; } i.e. (1) it passes through , or (2) comment was added other than default way of posting comments. For … Read more

How to get comments by post ID?

You can use get_comments. Function Reference/get comments $args = array(‘cat’ => ‘home’,’post_type’ => ‘post’)); $post_obj = new WP_Query($args); while($post_obj->have_posts() ) : $post_obj->the_post(); //display comments $comments = get_comments(array( ‘post_id’ => $post->ID, ‘number’ => ‘2’ )); foreach($comments as $comment) { //format comments } endwhile;

Commenting in user profile page?

Hi @Towfiq: Comments are related in the database to Posts. You’ll have to do a lot of work to get Comments to relate to Users. Have you considered creating a Custom Post Type for Users and then use either a user_meta field to store the post_id, or a postmeta field to store the user_id, or … Read more

Approve comment hook?

Just like posts, a comment can have an array of different statuses, so instead of naming a hook with each status, they have transition hooks, which tell you what status it had before and what’s the new status. In your case, this might do the trick: add_action(‘transition_comment_status’, ‘my_approve_comment_callback’, 10, 3); function my_approve_comment_callback($new_status, $old_status, $comment) { … Read more

How to make comments work for a post loaded per Ajax?

To quote the Codex on the have_comments function: This function relies upon the global $wp_query object to be set – this is usually the case from within The Loop The problem is that your ajax handler creates its own WP_Query object. Note that you are not calling the_post(), instead you are calling $posti->the_post(). Same logic … Read more

Non-threaded comment replies with link to original comment

This is my solution and not the proposed solution suggested on the WordPress forums. It turns out to be fairly easy, but involves a few steps. 1) Go to wp-admin->Settings->Discussion and switch off threaded comments. This will disable threading, which we want, but will also remove the ability for us to “reply to” a particular … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)