Same comment section on every page

With some testing this appears to be achievable with two filters. Firstly you want to set front end queries for comments to query for comments for all posts, instead of just the current post. That can be done like this: add_action( ‘pre_get_comments’, function( $comment_query ) { if ( ! is_admin() ) { $comment_query->query_vars[‘post_id’] = 0; … Read more

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’);