WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Customize comments popup link (images) (10 posts)

  1. deerstop
    Member
    Posted 6 years ago #

    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:

    <?php
    $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" />';

    comments_popup_link($leavecomment,$onecomment,$quancomment);
    ?>

    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. ^^

  2. Doodlebee
    Member
    Posted 6 years ago #

    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!

  3. deerstop
    Member
    Posted 6 years ago #

    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

  4. Doodlebee
    Member
    Posted 6 years ago #

    yeah, it should Sorry. Maybe try...

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

    perhaps?

  5. deerstop
    Member
    Posted 6 years ago #

    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. :(

  6. deerstop
    Member
    Posted 6 years ago #

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

  7. Doodlebee
    Member
    Posted 6 years ago #

    cool! Glad it worked out :)

  8. spotme10
    Member
    Posted 6 years ago #

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

  9. deerstop
    Member
    Posted 6 years ago #

    Strange. It worked with me.

  10. shane10101
    Member
    Posted 5 years ago #

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

    Thanks!

    Shane

Topic Closed

This topic has been closed to new replies.

About this Topic