Forums

[resolved] Using an image for a specific post's comment feed link (4 posts)

  1. mdziedzic
    Member
    Posted 3 years ago #

    I can track the comments on a specific post using the post_comments_rss_link() template tag:

    <?php comments_rss_link('RSS 2.0'); ?>

    But I can't figure out how to replace the HTML text link 'RSS 2.0' with an image.

  2. WizardRegis
    Member
    Posted 3 years ago #

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

    <?php post_comments_feed_link( $link_text = '<img src="yourimage">') ?>

    The Codex is a wonderful tool.

  3. mdziedzic
    Member
    Posted 3 years ago #

    Originally, when I tried

    <?php post_comments_feed_link( $link_text = '<img src="<?php bloginfo('template_url'); ?>/images/content/rss.png" width="42" height="25" alt="RSS" />') ?>

    I got the following error:

    PHP Parse error: syntax error, unexpected T_STRING

    I believe this is because my image path contains PHP:

    img src="<?php bloginfo('template_url'); ?>/images/content/rss.png"

    But the following workaround seems to work:

    <?php $themePath = get_bloginfo('template_url'); ?>
    <?php $imagePath = '<img src="' . $themePath . '/images/content/rss.png" width="42" height="25" alt="RSS" />'; ?>
    <?php post_comments_feed_link( $link_text = $imagePath) ?>
  4. tunghoy
    Member
    Posted 2 years ago #

    @mdziedzic, this is exactly what I was looking for. Thanks for posting it!

Topic Closed

This topic has been closed to new replies.

About this Topic