ThemeShaper Forums » Thematic

[closed]

How to edit a comment's meta?

(20 posts)
  • Started 4 years ago by Ben Collins
  • Latest reply from Marcky
  • This topic is resolved

Tags:

  1. Ben Collins
    Member

    Hi, this forum has been invaluable in helping me sort out the many design queries I've had working with thematic child themes. I've been struggling to solve the following though:

    If someone was to comment on a post then the line underneath their name (next to the avatar) would read:

    "Posted 17 March 2010 at 3:23 pm | Permalink | Edit"

    How would I modify the php code to remove the word "Posted", maybe remove the time and the Permalink and Edit buttons?

    Thanks in advance

    Posted 4 years ago #
  2. Ben,

    Try this in your "style.css"

    [code]
    #comments-list .comment-meta {
    display: none;
    }
    [code/]

    Posted 4 years ago #
  3. Ben Collins
    Member

    Hi @soren, thanks for the response.

    That does indeed work to remove all of the comment meta but I'd like to still keep the Date, so just remove the word "Posted" and Permalink.

    Any takers?

    Posted 4 years ago #
  4. (Seconded)

    Posted 4 years ago #
  5. Find this at "content-extension.php", been trying to filter out everything to only show the date in comments. I have not been able to do it at all. Any suggestions how?


    // Create comments link and edit link
    function thematic_postfooter_postcomments() {
    if (comments_open()) {
    $postcommentnumber = get_comments_number();
    if ($postcommentnumber > '1') {
    $postcomments = ' <span class="comments-link">';
    $postcomments .= get_comments_number() . __(' Comments', 'thematic') . '
    </span>';
    } elseif ($postcommentnumber == '1') {
    $postcomments = ' <span class="comments-link">';
    $postcomments .= get_comments_number() . __(' Comment', 'thematic') . '
    </span>';
    } elseif ($postcommentnumber == '0') {
    $postcomments = ' <span class="comments-link">';
    $postcomments .= __('Leave a comment', 'thematic') . '
    </span>';
    }
    } else {
    $postcomments = ' <span class="comments-link comments-closed-link">' . __('Comments closed', 'thematic') .'</span>';
    }
    // Display edit link
    if (current_user_can('edit_posts')) {
    $postcomments .= ' <span class="meta-sep meta-sep-edit">|</span> ' . thematic_postfooter_posteditlink();
    }
    return apply_filters('thematic_postfooter_postcomments',$postcomments);

    } // end thematic_postfooter_postcomments

    Posted 4 years ago #
  6. patrick
    Member

    Hi Ben,

    well it's a little bit of work but nothing too hard.

    First, have a look at the discussion.php file. There's a function inside called thematic_comments.

    Copy that function and paste it in your functions.php file.

    It starts from function thematic_comments … to … <?php }

    Rename the function from thematic_comments to what you want, something like mytheme_comments, then take out everything you want from there, specially the "Posted" you want to remove.

    Once you're ok with it, you should do the following :

    just below the <?php }, paste this :

    function my_callback() {
    	$content = 'type=comment&callback=mytheme_comments';
    	return $content;
    }
    add_filter('list_comments_arg', 'my_callback');

    Look carefully at the second line here. At the end it calls your function, mytheme_comments, so make sure that name and your function name are the same.

    That should do it. Keep me informed of the results !

    P.

    Posted 4 years ago #
  7. kgoodman
    Member

    Patrick,

    Great timing. Just happened to come in to search the forum and lo and behold, your answer. Works like a charm for me. Thanks so much!

    Kyndra

    Posted 4 years ago #
  8. patrick
    Member

    Hi Kyndra,

    Glad I could help !

    P.

    Posted 4 years ago #
  9. Patrick,

    I've been searching this for days!! Great!!! Only a few things more...

    I want it to be at the bottom of the comments and also change the dateformat to "d M Y" now there is " "%1$s "?

    Soren

    Posted 4 years ago #
  10. Opps forgot the code!


    <div class="comment-meta"><?php printf(__('%1$s', 'thematic')

    Posted 4 years ago #
  11. patrick
    Member

    Hi Soren,

    Below the line of code you just wrote, there should be get_comment_date(). Simply replace it with get_comment_date('d M Y'). You can also do get_comment_date('d / M / Y') or something similar.

    If you want it to be below the comment, just put the entire comment-meta <div> below the comment-content <div>

    And Voilà !

    P.

    Posted 4 years ago #
  12. Patrik,

    Salute!!

    many THANKS ! :)

    Soren

    Posted 4 years ago #
  13. patrick
    Member

    No worries !

    P.

    Posted 4 years ago #
  14. Ben Collins
    Member

    Hi patrick,

    Thanks kindly for getting back on this one, sorry for slow reply been away for a couple of days.

    I've been trying to get this working this morning but still having problems - removing the bits I want from the function doesn't appear to have any effect; I'm still seeing the whole "Posted 17 March 2010 at 3:23 pm | Permalink | Edit" in the comment meta

    The code I'm using in functions.php is:

    <?php

    // Custom callback to list comments in the Thematic style
    function mytheme_comments($comment, $args, $depth) {
    $GLOBALS['comment'] = $comment;
    $GLOBALS['comment_depth'] = $depth;
    ?>
    <li id="comment-<?php comment_ID() ?>" class="<?php thematic_comment_class() ?>">
    <div class="comment-author vcard"><?php thematic_commenter_link() ?></div>
    <div class="comment-meta"><?php printf(__('%1$s', 'thematic'),
    get_comment_date() ); ?></div>
    <?php if ($comment->comment_approved == '0') _e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'thematic') ?>
    <div class="comment-content">
    <?php comment_text() ?>
    </div>
    <?php // echo the comment reply link with help from Justin Tadlock http://justintadlock.com/ and Will Norris http://willnorris.com/
    if($args['type'] == 'all' || get_comment_type() == 'comment') :
    comment_reply_link(array_merge($args, array(
    'reply_text' => __('Reply','thematic'),
    'login_text' => __('Log in to reply.','thematic'),
    'depth' => $depth,
    'before' => '<div class="comment-reply-link">',
    'after' => '</div>'
    )));
    endif;
    ?>
    <?php }

    function my_callback() {
    $content = 'type=comment&callback=mytheme_comments';
    return $content;
    }
    add_filter('list_comments_arg', 'my_callback');

    ?>

    Any ideas? Thanks again

    Ben

    Posted 4 years ago #
  15. patrick
    Member

    It's weird cause I've just copied your code in my functions.php file and it worked straight. The only change i've made is, because I have other functions in my file, removed the <?php at the beginning and ?> at the end of your code.

    If it's the only function you have in your file, leave those opening and closing statement, if not, remove them.

    Other than that, hmmm, do you have a comments.php file in your child theme folder ?

    Give me a url so I can have a look.

    Thanks,

    P.

    Posted 4 years ago #
  16. Ben Collins
    Member

    Hi Patrick, thanks again for getting back.

    It's working now! I re-installed thematic and then the code above worked a treat. I think that I must have altered one of the parent files in the original thematic theme way back (when I was not fully understanding the parent/child theme model).

    Thanks massively for your help.

    Cheers, Ben

    Posted 4 years ago #
  17. patrick
    Member

    Glad it's all good for you !

    P.

    Posted 4 years ago #
  18. dorabelle
    Member

    To advance your editing of meta data, you should try out the "All in One SEO Pack" plugin for WP, its really easy to go through and edit meta for about everything, and can help you promote your websites pretty well, I use it. good luck

    Posted 4 years ago #
  19. Hi!

    I've been playing with Thematic for a couple of weeks, and I'm getting to know the filters & hooks stuff. Now I'm trying to add some markup to the comments, my goal is to float to the right the meta information of each comment by enclosing comment-author & comment-meta into a "comments-info" custom div.

    I've followed Ian's Comments Guide and realized the comments template he is proposing is actually the comments.php template in Thematic 0.9.7.7.

    Should I need any apply_filter stuff to use the custom_comments() function? I've also followed the steps by patrick and after adding my_callback() and my comments-info doesn't appear either.

    Thankyou all for the awesome help :)

    Posted 4 years ago #
  20. Now it works! Here's how I got it following this thread:

    1. Read the Comments Template Customization Guide mentioned earlier, and add custom_comments() to your functions.php

    2. Copy comments.php from Thematic parent theme to your child theme.

    3. In your own comments.php, find wp_list_comments(list_comments_args()); around line 34.

    4. Modify it to wp_list_comments('type=comment&callback=childtheme_comments');

    Voilá.

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.