WordPress.org

Forums

Adaption
Awesome Theme (2 posts)

  1. marketraisen
    Member
    Posted 11 months ago #

    How the hell do I remove the link from a comment date though? I cant seem to find the code anywhere in the theme files.

  2. Kathryn
    Automattic Happiness Engineer
    Posted 10 months ago #

    The comment date in most WordPress themes is meant to serve as a permalink to the individual comment.

    You'll find this functionality in inc/template-tags.php, within the function adaption_comment on lines 104-108.

    <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
    <time datetime="<?php comment_time( 'c' ); ?>">
    <span class="post-date"><?php printf( _x( ', %1$s at %2$s', '1: date, 2: time', 'adaption' ), get_comment_date(), get_comment_time() ); ?></span>
    </time>
    </a>

    To remove the link will require a few steps.

    1. First, you'll need to create a child theme, so your changes won't be overwritten when you update the theme. If you're new to child themes, you can explore these guides:

    http://codex.wordpress.org/Child_Themes
    http://op111.net/53/
    http://vimeo.com/39023468

    2. Once your child theme is set up, you'll need to create a functions.php file (if you haven't already) and add the function you want to override. Be sure to use a plain-text editor when creating this file.

    3. Add the function adaption_comment to your functions file. You'll want to copy everything from line 68 through line 127, inclusive, from inc/template-tags.php into your functions.php file. Be sure to start the file with an opening <?php tag if you don't have one already. No end ?> tag is needed.

    4. Now, you'll want to remove the link around the date from the comment function you've placed in your child theme's functions.php folder.

    That means taking this chunk of code in your functions.php:

    <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
    <time datetime="<?php comment_time( 'c' ); ?>">
    <span class="post-date"><?php printf( _x( ', %1$s at %2$s', '1: date, 2: time', 'adaption' ), get_comment_date(), get_comment_time() ); ?></span>
    </time>
    </a>

    And removing the anchor tag around the time stamp so it now looks like this:

    <time datetime="<?php comment_time( 'c' ); ?>">
    <span class="post-date"><?php printf( _x( ', %1$s at %2$s', '1: date, 2: time', 'adaption' ), get_comment_date(), get_comment_time() ); ?></span>
    </time>

    5. Activate your child theme.

    I tested this on my end and it worked to remove the link on comment dates. Good luck!

Reply

You must log in to post.

About this Theme

About this Topic