Get all comments associated with a specific page ID (comment_post_ID)

Based on developer documents of get_comments functions, it is using args like WP_Comment_Query::__construct Method which is accepts post_id in the argument’s array. So, the code will be like: foreach($assignments as $assignment) { echo $assignment->post_title; $args = array( ‘number’ => 0, ‘status’ => ‘approve’, // shows all comments, but it shouldn’t ‘post_id’ => $assignment->ID ); $comments … Read more

Display date and time into post edit comments section

Here is the answer given by Ferman on wpfr.net function date_commentaire( ){ $comments = get_comments( array( ‘post_id’ => get_the_ID() )); if ( doing_action( ‘wp_ajax_get-comments’ ) ) foreach ( $comments as $comment ) : $a = $comment->comment_ID; $b = get_comment_ID(); $date_comment = get_comment_date(); $time_comment = get_comment_time(); if ( $a==$b ) echo ‘<p class=”commentaire-date”>’.’Commentaire N°: ‘.$comment->comment_ID.’ du: … Read more

Allow comments only for custom post type

if you are using the code from the thread you linked to, to disable the comments on post and pages then when a new post/page is added it should have the comments automatically disabled. The existing posts/pages will have comments enabled unless you uncheck the “Allow comments” checkbox when editing a post. A quick and … Read more

Random output of comments using a shortcode

Easy thing would be to override comment query and set orderby property to rand. function wpse381090_comment_query_rand( $args ) { $args[‘orderby’] = ‘rand’; return $args; } add_filter(‘comments_template_query_args’, ‘wpse381090_comment_query_rand’);

Automatically register users with comments

There are a number of functions you can use: register_new_user wp_create_user wp_insert_user The first function being the most simple to use and the last function gives you many more options – it depends what you want to do. You can create the new account when the comment is posted using the comment_post hook. You will … Read more

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