Support » Fixing WordPress » return the title of a thumbnail with get_post_thumbnail_id

  • Zaccety

    (@zaccety)


    Does anyone know how I can return the name (i.e. Title) of an image being used as a thumbnail with the new Page Image feature?

    I can return the ID using:

    get_post_thumbnail_id($post_id);

    but I want to return the name of the image so I can replace a part of it and then use that to call a different, yet similar, image.

    Could be I’m using a clumsy-thumbed method to achieve what I want but *blush* it’s the only way I know how.

Viewing 1 replies (of 1 total)
  • $thumb_id = get_post_thumbnail_id( $post->ID );
    if( !empty( $thumb_id ) )
    	print get_the_title( $thumb_id );
Viewing 1 replies (of 1 total)
  • The topic ‘return the title of a thumbnail with get_post_thumbnail_id’ is closed to new replies.