WordPress.org

Ready to get started?Download WordPress

Forums

Add id="" to thumbnails in index (5 posts)

  1. Sinopa
    Member
    Posted 2 years ago #

    Does anyone know how I can add id="" to thumbnails in index.

    <img class="alignleft size-thumbnail wp-image-104" title="my_image" src="my_image-150x150.jpg" alt="" width="150" height="150" />

    WordPress just adds class, but I need id too :)

  2. nsathees
    Member
    Posted 2 years ago #

    Why do you need to add id? You can access it with the parent tag.
    for example if the code looks like this . . .

    <div id="post">
    <img class="alignleft size-thumbnail wp-image-104" title="my_image" src="my_image-150x150.jpg" alt="" width="150" height="150" />
    </div>

    Then you can access it by #post img{width=200px;}

  3. Sinopa
    Member
    Posted 2 years ago #

    I need the ID tag because I'm adding custom jquery tooltips to thumbnail images.

  4. maxemil
    Member
    Posted 2 years ago #

    do something like this:

    $attr = array(
      'id' => 'slide_thumb_'.$post->ID
    );
    echo get_the_post_thumbnail( $post->ID, 'thumbnail', $attr );

    Then you can use #slide_thumb_<your_post_id> as selector.

    also see http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

    BR\ME

  5. Sinopa
    Member
    Posted 2 years ago #

    Could you please tell me how to implement that?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags