WordPress.org

Ready to get started?Download WordPress

Forums

Can I add something like "rel=$post_id" to post thumbnail? (2 posts)

  1. bojroninad
    Member
    Posted 1 year ago #

    I need to add a rel attribute(which is equal to post id) to every post thumbnail image. It can be done by simple preg_replace, but that will reside in the function.php file. I can not think of a way to retrieve the subjected post id from there. However, I must need the post id in the attribute.
    I actually want the output like this:
    <img src="#something" rel="#i_need_the_post_id_here"/>
    Any clue on this?

  2. vahidd
    Member
    Posted 1 year ago #

    try this:
    <img src="#something" rel="#<?php echo $post->ID; ?>"/>

Topic Closed

This topic has been closed to new replies.

About this Topic