Override comments.php template with plugin

How can I override default theme/WP Core comments.php template with my own in the plugin? I searched for different solutions, but they don’t work for me. Or how to hook to the end of any post (even custom post type) to display my custom comments? 1 Answer 1 The comments_template hook: add_filter( ‘comments_template’, function ( … Read more

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? … Read more

What does the “$depth” parameter in the Walker_Comment stand for?

I’m trying to write a custom comment class for my comments and I’ve been trying to de-construct the code for quite a while, here it is: class Custom_Comment_Walker extends Walker_Comment { var $tree_type=”comment”; var $db_fields = array( ‘parent’ => ‘comment_parent’, ‘id’ => ‘comment_ID’ ); // constructor – wrapper for the comments list function __construct() { … Read more

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 … Read more

How to add a privacy-checkbox in comment-template?

i need to add a privacy-checkbox to the file comment-template.php. I created the checkbox and a paragraph and it looks fine, so far. <input type=”checkbox” name=”privacy” value=”privacy-key” class=”privacyBox” aria-req=”true”><p class=”pprivacy”>Hiermit akzeptiere ich die <a target=”blank” href=”http://wp.cloudstarter.de/?page_id=156″>Datenschutzbedingungen</a><p> Now, i want to connect this checkbox with the submit-button, so that a user HAS to accept the privacy … Read more

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 … Read more

Remove “at” string from wordpress comment date

I’m using the following code to format the author’s comment date and remove the time: function my_change_comment_date_format( $date, $date_format, $comment ) { return date( ‘d M Y’, strtotime( $comment->comment_date ) ); } add_filter( ‘get_comment_date’, ‘my_change_comment_date_format’, 10, 3 ); function wpb_remove_comment_time($date, $d, $comment) { if ( !is_admin() ) { return; } else { return $date; } … Read more

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 … Read more