Support » Themes and Templates » Customize comments popup link (images)

  • Resolved deerstop


    Hello. I’m trying to insert images in my comments_popup_link, so under the entry won’t be written “Comment”, but some picture could be seen instead.
    I’m hopeless in php, but using logic and this post, I managed to write this:

    $leavecomment='<img src="' .TEMPLATEPATH .
    '/leavecomm.gif" width="134" height="23"
    alt="Leave comment" align="middle"
    style="padding-bottom: 9px;" border="0" />';

    $onecomment='<img src="' .TEMPLATEPATH . '/comm.gif" alt="Comments: 1" width="90" height="23" align="middle" style="padding-bottom: 9px;" border="0" /> 1';

    $quancomment='<img src="' .TEMPLATEPATH . '/comm.gif" alt="Comments:" width="90" height="23" align="middle" style="padding-bottom: 9px;" border="0" />';


    The problem is that TEMPLATEPATH creates absolute path (/home/public_html/…), so the path to images is absolute and of course images don’t appear. I’ve tried to use bloginfo('template_directory');, but php-code doesn’t work.
    And the second problem: I don’t know how to display quantity of comments this way – like “Comments 5” with images: “IMG 5”

    Hope my english is understandable. ^^

Viewing 9 replies - 1 through 9 (of 9 total)
  • I’m not sure what you’re trying to do….you’re trying to replace the “Comments” link under each post with an image instead of text? That’s pretty easy to do – without all of that stuff you’ve put in there. Just replace the text with an image in the index.php file:

    $img = '<img src="<?php bloginfo('template_directory'); ?>/images/comment_image.gif" alt="" />';

    <?php comments_popup_link($img, $img, '%' . $img); ?>

    That should just replace the comments text with the image you want. Unless I’m misunderstanding your question!

    That’s exactly what I’ve needed! 🙂 But as far as I can understand, $img=blahblah should be within <?php ?> and this way <?php bloginfo(‘template_directory’); ?> isn’t working

    yeah, it should Sorry. Maybe try…

    $url = echo bloginfo('template_directory');
    $img = echo '<img src="' . $url . '" alt="">';
    comments_popup_link($img, $img, '%' . $img); ?>


    The result is the same as when using bloginfo(‘template_directory’) in my first variant. That bastard just ignores <img> tags, simply writes the full url to image and comment links near it. 🙁

    Oh, I’ve found the solution!
    You just have to use get_bloginfo(‘template_directory’) instead of bloginfo('template_directory');

    cool! Glad it worked out 🙂

    I can not for the life of me get this to work. It keeps giving me a major error.

    Strange. It worked with me.

    Could someone give me a simple explanation of the difference between using bloginfo(‘template_directory’) and TEMPLATEPATH for me? I’d sure appreciate it!



Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Customize comments popup link (images)’ is closed to new replies.