Using Simple Hooks to remove comment date

Community Forums Forums Design Tips and Tricks Using Simple Hooks to remove comment date

This topic is: not resolved

Tagged: , , ,

This topic contains 10 replies, has 4 voices, and was last updated by  braddalton 8 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #25815

    Nat
    Participant
    Post count: 8

    Hi, is there anyway to use Simple hooks plug in to remove the dates and time from comments. If not, where is the code in CSS File to remove it?

    Using metro themehttp://turkishtravelblog.com

    #25817

    braddalton
    Participant
    Post count: 7458

    This CSS code will hide the date and time:

    .comment-meta {
    display: none;
    }
    

    Paste it at the end of your child themes style.css file.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #25849

    stacyvlasits
    Participant
    Post count: 6

    Brad’s solution is probably the best way to solve your problem, but it is a teeny bit hacky in that it leaves html on your page that you really don’t want.

    In case anyone is interested, here is a complicated (but cleaner) way to implement this.

    In your functions.php file  add_filter('genesis_comment_list_args', 'my_custom_comment_list_args'). Then define the function:

    function my_custom_comment_list_args($args){

    $args = array(
    'callback' = 'custom_comment_callback_no_date',

    )

    }

    Define a function like this in functions.php (it is a copy of the callback that genesis uses, only without the comment date/time):


    function custom_comment_callback_no_date( $comment, $args, $depth ) {

    $GLOBALS['comment'] = $comment; ?>

    <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">

    <?php do_action( 'genesis_before_comment' ); ?>

    <div class="comment-header">
    <div class="comment-author vcard">
    <?php echo get_avatar( $comment, $size = $args['avatar_size'] ); ?>
    <?php printf( __( '<cite class="fn">%s</cite> <span class="says">%s:</span>', 'genesis' ), get_comment_author_link(), apply_filters( 'comment_author_says_text', __( 'says', 'genesis' ) ) ); ?>
    </div><!-- end .comment-author -->

    </div>

    <div class="comment-content">
    <?php if ( $comment->comment_approved == '0' ) : ?>
    <p class="alert"><?php echo apply_filters( 'genesis_comment_awaiting_moderation', __( 'Your comment is awaiting moderation.', 'genesis' ) ); ?></p>
    <?php endif; ?>

    <?php comment_text(); ?>
    </div><!-- end .comment-content -->

    <div class="reply">
    <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    </div>

    <?php do_action( 'genesis_after_comment' );

    /** No ending </li> tag because of comment threading */

    }

    #25852

    Nat
    Participant
    Post count: 8

    Worked a treat. Thank you very much Brad

    #25854

    Nat
    Participant
    Post count: 8

    Sorry Stacy, did not see your reply because was working on the style sheet.

    Unfortunately all of what you said just went totally straight over the top of my head. I am novice when it comes to editing and that is why I wanted to use the simple hooks plug in

    #25883

    braddalton
    Participant
    Post count: 7458

    No worries Nat.

    Stacy, i was actually going to do that but with a smaller amount of code using this:

    http://codex.wordpress.org/Function_Reference/delete_comment_meta

    and write this into a small function but didn’t think leaving the comment meta for date and time in the source code would be a problem. Still interested to try and make it work.

    Which Genesis file did you grab all the code from?


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #25894

    stacyvlasits
    Participant
    Post count: 6

    Nat, as I noted, Brad’s solution is almost certainly the right choice for you (and probably for most situations).

    Also, Brad, that function really looks like the way to go.

    I took the code from the genesis_comment_callback which is in genesis/lib/structure/comments.php

    #36526

    braddalton
    Participant
    Post count: 7458

    Thanks Stacy. Missed your comment last time.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #56913

    Jenny
    Participant
    Post count: 35

    What if I just wanna remove the TIME from the comment date? How would I go about doing that. I’m using 2.0 btw~

    #56918

    braddalton
    Participant
    Post count: 7458

    This CSS code will hide but not remove from the database, all comment meta for date from all posts.

    https://gist.github.com/braddalton/6253744


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #56939

    braddalton
    Participant
    Post count: 7458

    Removing the time can’t be done with CSS without removing the date as well.

    You would need to use the WordPress comment form args to filter the output of the comment meta data.

    $args: An array of arguments for controlling the output of the comment form.

    There’s no information on filtering it http://codex.wordpress.org/Function_Reference/delete_comment_meta


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.