WordPress.org

Ready to get started?Download WordPress

Forums

return the title of a thumbnail with get_post_thumbnail_id (2 posts)

  1. Zaccety
    Member
    Posted 4 years ago #

    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.

  2. Michael Fields
    Themer
    Posted 4 years ago #

    $thumb_id = get_post_thumbnail_id( $post->ID );
    if( !empty( $thumb_id ) )
    	print get_the_title( $thumb_id );

Topic Closed

This topic has been closed to new replies.

About this Topic