• Hi there,

    I’m working with this code:
    <?php the_post_thumbnail('full'); ?>

    What I’m trying to do is wrap it in a this tag: <img> because I want to add Structured Data Markup like so:

    <img itemprop="image" class="alignright size-full wp-image-753" alt="" src="image.jpg"/>

    Does anybody know how to do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi gotmedia,

    If I understand your question correctly, you are interested in adding the itemprop="image" portion? The function the_post_thumbnail() takes a second argument that allows you to pass in an array of HTML attributes. Thus to create this you could write the following:

    <?php
      the_post_thumbnail(
        'full',
        array(
            'itemprop' => 'image',
            'class' => 'alignright size-full wp-image-753',
            'alt' => 'image.jpg'
        )
      )
    ?>

    If I am not understanding you correctly, and you are interested in using the new html 5 image tag or something else then you can always query for just the image src like so:

    <?php
      $imageUrl = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
    ?>

    I hope that this helps!

    Thread Starter gotmedia

    (@gotmedia)

    Actually, the first code was PERFECT! Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Schema.org: Editing the_post_thumbnail code?’ is closed to new replies.