My current theme comments are displayed using following code.

         <ol class="comment-list">
                wp_list_comments( array(
                    'style'      => 'ol',
                    'short_ping' => true,
                ) );

I need to remove "a href" part.I mean their should not be linked to the comment author website.

I check wp_list_comments() from codex, but I could not find how to remove <a href part.


Deep down the function uses get_comment_author_link() to output the author name. That function is filterable. Inside the function it checks if the author has a URL and wraps the name in a link to it if it exists. We can use the get_comment_author_link filter to just output the name, and ignore the URL. This is pretty simple, since the callback for this filter gets the author name as one of its arguments, so we just need to pass it through untouched:

function wpse_284352_author_link( $author_link, $author ) {
    return $author;
add_filter( 'get_comment_author_link', 'wpse_284352_author_link', 10, 2 );

EDIT: It's actually even simpler, the URL has its own filter, which means that can be filtered with one of WordPress' built in functions in one line:

add_filter( 'get_comment_author_url', '__return_empty_string' );

You could create your own walker and customize its structure. Note that using a filter will affect "all" instances of wp_list_comments(), so you are advised to customize your comments by using a walker. Here's a basic example:

function my_comment( $comment, $args, $depth ) {
    $GLOBALS['comment'] = $comment; ?>
    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
        <div id="comment-<?php comment_ID(); ?>" class="comment-wrap">
            <div class="comment-head comment-author vcard"><?php
                echo get_avatar( $comment, 60 );
                if ( comments_open() ){
                                'depth' => $depth,
                                'max_depth' => $args['max_depth'], 
                                'reply_text' => __( 'Reply' ) 
                <div class="comment-meta commentmetadata">
                    <div class="comment-date"><?php
                        /* translators: 1: date, 2: time */
                        printf( __( '%1$s at %2$s' ),
                        ); ?>
                    edit_comment_link( __( 'Edit' ), '', '' );?>
            <div class="comment-content comment-text"><?php
                if ( $comment->comment_approved == '0' ) { ?>
                    <em><?php _e( 'Your comment is awaiting moderation.'); ?></em><br /><?php
                comment_text(); ?>

Now you can define the callback in wp_list_comments():

        'callback' => 'my_comment' ,
        'style'    => 'ol'

This will render the comments without a link to them. You can fully customize the output comments. Further information and complex examples are provided in the codex page.

  • @JackJohansson I currently accepted the Jacob Peattie answer because it gives the quick solution for me. But long term wise it has problem as you said... So I will try your answers and I will mark your answer as accepted answer... Please give me a few days for that because currently I just wanted to remove <a href as soon as possible. – I am the Most Stupid Person Oct 31 '17 at 3:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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