WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP - how to get the medium thumbnail url? (5 posts)

  1. utnalove
    Member
    Posted 1 year ago #

    Hello, I am now using this:

    <meta property="og:image" content="<?php echo wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ) ?>" />

    But it gives the URL of the small thumbnail. I need to have the URL of the medium thumbnail. What is the right code?

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

  3. utnalove
    Member
    Posted 1 year ago #

    in that page I see only how to get the thumbnail, but I need the URL of the medium thumbnail..

  4. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    <meta property="og:image" content="<?php
     if ( has_post_thumbnail()) {
       $medium_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium');
       echo '<a href="' . $medium_image_url[0] . '" title="' . the_title_attribute('echo=0') . '">';
       echo get_the_post_thumbnail($post->ID, 'thumbnail');
       echo '</a>';
     }
    ?>" />
  5. utnalove
    Member
    Posted 1 year ago #

    Thank you so much! Very useful

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.