ThemeShaper Forums » Thematic

Edit wp_list_comments() with functions.php

(3 posts)
  • Started 9 years ago by Kabitzin
  • Latest reply from Kabitzin
  • This topic is resolved
  1. I would like to call a WP plugin that displays the number of comments that a person has posted on my blog. This plugin is called with:

    <?php comment_counter();?>

    I wanted to use the functions.php file in my child theme to insert this plugin call right after the commenter's name (e.g. if I have posted 100 comments on your blog, my comment would show "Kabitzin (100)" instead of just "Kabitzin")

    However, I am not sure how to piggyback off the thematic_comments function that is called in discussion.php in the parent theme. How do I add this plugin code to wp_list_comments() with functions.php?

    All I want to do is replace this line:

    <div class="comment-author vcard">
    <?php thematic_commenter_link() ?>
    </div>

    with this line:

    <div class="comment-author vcard">
    <?php thematic_commenter_link() ?>
    <?php if (function_exists('comment_counter'))  {  comment_counter('email',' <small>(',')</small>');  } ?>
    </div>

    I tried

    function childtheme_comments($comment, $args, $depth) {
    
    ===== EXACT COPY OF thematic_comments
    
    <div class="comment-author vcard">
    <?php thematic_commenter_link() ?>
    <?php if (function_exists('comment_counter'))  {  comment_counter('email',' <small>(',')</small>');  } ?>
    </div>
    
    ===== THE REST OF thematic_comments
    add_filter ('thematic_comments', 'childtheme_comments');

    but nothing happened. I also tried add_action instead of add_filter and it made no difference.

    Posted 9 years ago #
  2. Hey Kabitzin

    .. and welcome on board. Unfortunately there's no hook for an action or a filter right now. This might change in the future.

    For the moment try this one:

    Put your childtheme_comments() without add_filter() into your functions.php. Copy comments.php in your child theme directory, change the line:

    <?php wp_list_comments('type=comment&callback=thematic_comments'); ?>

    to:

    <?php wp_list_comments('type=comment&callback=childtheme_comments'); ?>

    Cheers,

    Chris

    Posted 9 years ago #
  3. Worked like a charm! Thanks so much!

    Posted 9 years ago #

RSS feed for this topic

Reply

You must log in to post.