0

This question already has an answer here:

Is it possible to change the comment-meta fields?

I have tried searching the file structure and cannot see what function is writing it - all I want to do is change the word "says"

<ol class="comment-list">
            <li id="comment-2" class="comment byuser comment-author-james bypostauthor even thread-even depth-1 parent">
    <article id="div-comment-2" class="comment-body">
        <footer class="comment-meta">
            <div class="comment-author vcard">
                                        <b class="fn">james</b> <span class="says">says:</span>                 </div><!-- .comment-author -->

            <div class="comment-metadata">

Thanks James

marked as duplicate by Dave Romsey, cjbj, bueltge, fuxia Dec 9 '16 at 14:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What theme are you using? – Emil Dec 7 '16 at 11:10
0

In your theme need to find wp_list_comments it accepts some arguments. One of these arguments is the format. The default format is html5, but there is one more in /wp-includes/class-walker-comment.php called xhtml.

Here are all the arguments for the wp_list_comments:

* @param string|array $args {
 *     Optional. Formatting options.
 *
 *     @type object $walker            Instance of a Walker class to list comments. Default null.
 *     @type int    $max_depth         The maximum comments depth. Default empty.
 *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
 *     @type string $callback          Callback function to use. Default null.
 *     @type string $end-callback      Callback function to use at the end. Default null.
 *     @type string $type              Type of comments to list.
 *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
 *     @type int    $page              Page ID to list comments for. Default empty.
 *     @type int    $per_page          Number of comments to list per page. Default empty.
 *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
 *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
 *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
 *     @type string $format            How to format the comments list.
 *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
 *     @type bool   $short_ping        Whether to output short pings. Default false.
 *     @type bool   $echo              Whether to echo the output or return it. Default true.
 * }
 * @param array $comments Optional. Array of WP_Comment objects.
 */
function wp_list_comments( $args = array(), $comments = null ) {

You define your format.

wp_list_comments( ... , 'myformat', ...);

// create a callback
if( function_exists( 'myformat_comment' ) )
{
    $args['format'] = 'myformat';
    $args['callback'] = 'myformat_comment';
}

Within a new function.

function myformat_comment( $comment, $depth, $args ){}

based on:

protected function html5_comment( $comment, $depth, $args ) {
        $tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
?>
        <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>>
            <article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
                <footer class="comment-meta">
                    <div class="comment-author vcard">
                        <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
                        <?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<b class="fn">%s</b>', get_comment_author_link( $comment ) ) ); ?>
                    </div><!-- .comment-author -->

                    <div class="comment-metadata">
                        <a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>">
                            <time datetime="<?php comment_time( 'c' ); ?>">
                                <?php
                                    /* translators: 1: comment date, 2: comment time */
                                    printf( __( '%1$s at %2$s' ), get_comment_date( '', $comment ), get_comment_time() );
                                ?>
                            </time>
                        </a>
                        <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
                    </div><!-- .comment-metadata -->

                    <?php if ( '0' == $comment->comment_approved ) : ?>
                    <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p>
                    <?php endif; ?>
                </footer><!-- .comment-meta -->

                <div class="comment-content">
                    <?php comment_text(); ?>
                </div><!-- .comment-content -->

                <?php
                comment_reply_link( array_merge( $args, array(
                    'add_below' => 'div-comment',
                    'depth'     => $depth,
                    'max_depth' => $args['max_depth'],
                    'before'    => '<div class="reply">',
                    'after'     => '</div>'
                ) ) );
                ?>
            </article><!-- .comment-body -->
<?php
    }
0

A simple way to achieve the desired effect would be to filter get_comment_author_link and set the "says" class to non-display in your stylesheet:

CSS:

.says {
    display: none ; 
}

The above may seem a little forced or inelegant, but it's simple, and the approach is essentially how the WordPress annual themes that don't like to say "says" do it, although they may use a more elaborate, belt + suspenders approach. "2015" knocks out says by doing this:

.says, .screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    height: 1px;
    overflow: hidden;
    position: absolute !important;
    width: 1px;
}

Either way, now that you're no longer saying says, you can say something else:

functions.php or plug-in:

add_filter( 'get_comment_author_link' , 'wpse_better_than_says' ) ;

function wpse_better_than_says( $link ) {

    //avoid pesky warning notices by declaring variable
    $better = '' ;

    //use in comment threads (not widgets and things) only: 
    if ( is_singular() && in_the_loop() ) {

        $better = '<span class="opines">&nbsp;opines herewith:</span>' ;

    }

    return $link . $better ; 

}

Not the answer you're looking for? Browse other questions tagged or ask your own question.