Articles of comments template

Add classname comment template from functions.php

I want to add an extra classname to my comment template (the div wrapper before the post itself) which is stated in functions.php. The classname in functions.php is an extra field in my users profile section and I want to get that string and add it as an extra classname in my comment template. The […]

Change HTML Produced by wp_list_comments()

I am developing a WordPress theme for which I would like each comment’s timestamp wrapped in in a <span> element for the sake of styling it with CSS rules. However, the wp_list_comments() function as I use it in my theme’s comments.php template does not seem to provide options to alter the HTML produced: <ol class=”comment-list”> […]

how to get the comment ID in the front end when the REPLY button is clicked?

I think I might be able to parse the URL for the replytocom parameter and get the comment ID from that. However, it would mean that my plugin would not be fully compatible with other plugins that can remove this parameter (most notably Yoast SEO). Plus, it feels a bit hacky. Is there another way? […]

Warning: call_user_func_array() expects parameter 1 to be a valid callback, func

I have installed WordPress in my localhost server. I am a creating custom menu. When I try to remove the existing “primary” menu from it, I get this error Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘tnc-remove_default_menu’ not found or invalid function name in F:\AppServ\www\itexperthouseen\wp-includes\comment-template.php inn my admin page. Can anyone […]

Order of Operation for these three hooks

What is the order of firing for these three hooks? add_filter( ‘comments_array’, array( $this, ‘BuildCommentsArray’ ), 10, 2 ); add_action( ‘preprocess_comment’, array( $this, ‘write’ ), 10, 1 ); add_action( ‘comment_post’, array( $this, ‘add_meta’ ), 10, 1 ); This is what I’m trying to achieve, but I’m getting a loop. In BuildCommentsArray, posts from a forum […]

How to get last comments but not from admin (or other specific user role/capability)?

I’m using get_comments to show lastest comments i.e.: <?php global $comments, $comment; $comments = get_comments( array( ‘number’ => ‘5’, ‘status’ => ‘approve’, ‘post_status’ => ‘publish’ ) ); foreach ( (array) $comments as $comment) { echo ‘<li>’.$comment->comment_author.’ said ‘.$comment->comment_content .'</li>’ } ;?> Is there some way to override admin comments?! I know this tip using SQL […]

Showing comments only to same custom user role

Is there a way I could show only the comments by a particular user role to his same user role? For example: The logged in user belongs to the “Advertisers” user role, he should only see the comments made by him and all users under his role. Thank you.

How to display comments on different page

I am creating a reviews site and I want to display the customer reviews (comments) on a separate page from the single-restaurant.php. I’ll just have a link that says (Read reviews/ add yours). I created a custom comments template and called it comments-side.php and this is what I have in it: <?php /** * Comments […]

How to hide “Trackback” on paginated comments

My Setup: On my Single’s page I have used this comments_template(”, true); to separate Trackback’s & regular comments. The Heading “Trackbacks for this post” shows up only if a post has trackbacks. Now the issue is, if the comments are paginated: On First page, the trackback are shown and below them the regular comments are […]

How can I limit the number of comments per registered user per day?

I found this code on WPSE: global $current_user, $post; $args = array( ‘user_id’ => $current_user->ID, ‘post_id’ => $post->ID ); $usercomment = get_comments( $args ); if ( 1 <= count( $usercomment ) ) { echo ‘disabled’; } else { comment_form(); } Note: It seems to limit the number of comments per post per user. I want […]