Remove “at” string from wordpress comment date

Most likely, the ‘at’ is coming from the value of $comment->comment_date. If that is the case, and since we have to do with string, you could pass it from str_replace first, in order to remove the ‘ at’, like: function my_change_comment_date_format( $date, $date_format, $comment ) { return date( ‘d M Y’, strtotime( str_replace(” at”, “”, … Read more

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

Yay! We got filters! Wrapping the result of the $wpdb comments query right into a filter callback (and a plugin) is the nice way of handling comments. /* Plugin Name: »Kaisers« Comments without admin comments */ ! defined( ‘ABSPATH’ ) AND exit; add_filter( ‘comments_array’, ‘wpse_61072_comments_without_admin’, 20, 2 ); function wpse_61072_comments_without_admin( $comments, $post_id ) { foreach … Read more

adding a text message beside the comment submit button

You should not edit the WordPress core files! If you have comment_id_fields() in your comments template, like this: <p class=”form-submit”> <input name=”submit” type=”submit” id=”<?php echo esc_attr( $args[‘id_submit’] ); ?>” value=”<?php echo esc_attr( $args[‘label_submit’] ); ?>” /> <?php comment_id_fields( $post_id ); ?> </p> you might use: add_filter(“comment_id_fields”,”my_submit_comment_message”); function my_submit_comment_message($result){ return $result.” <span>(your message will only be … Read more

How can I show comments in random order?

Never actually had a need for this but you will need to use the WP_Comment_Query function. There is this handy comments query generator online to customize this query easily. But wait, it doesn’t allow you to select a random order. No worries just add or replace the orderby parameter: ‘orderby’ => ‘rand’ This should return … Read more

Change WordPress comments url / word

In your functions.php add ( there are other rules relating to comment pages you can see them all with Rewrite Rules Inspector plugin, this one just covers the case you mention ) add_rewrite_rule ( ‘(.?.+?)/customname-([0-9]{1,})/?$’, ‘index.php?pagename=$matches[1]&cpage=$matches[2]’, ‘top’ ); you’ll also need to find in your theme ( possibly in your function.php ) where the comments … Read more

customize comment form

This code will allow you to customize the comment field labels and will move the comment form below the fields. Add the code to your functions.php or to a plugin. To change the labels, modify the Name CUSTOMIZED, Email CUSTOMIZED, and Website CUSTOMIZED, and Comment * CUSTOMIZED text. /** * Customize comment form default fields. … Read more

How do I change parameters without changing the core

If you scroll further down the comment-template.php file, you’ll notice that the next available filter you can use is comment_form_defaults. With this filter you can change the default comment form configuration. add_filter( ‘comment_form_defaults’, ‘filter_comment_form_defaults’ ); function filter_comment_form_defaults( $defaults ) { $defaults[‘comment_field’] = sprintf( ‘<p class=”comment-form-comment”>%s %s</p>’, sprintf( ‘<label for=”comment”>%s</label>’, _x( ‘Please leave a comment…’, ‘Comment … Read more

Passing arguments to wp_list_comments callback function

Finally I figured it out. you may simply add your arguments to the wp_list_comments as associative key => value pairs like this: $args = array( ‘callback’ => ‘my_callback’, ‘avatar_size’ => 48, ‘type’ => ‘comment’, ‘arg1’ => $arg1 ); wp_list_comments( $args ); and then in your my_callback you have: function my_callback( $comment, $args, $depth ) where … Read more