Viewing 4 replies - 1 through 4 (of 4 total)
  • Anyone? This could be really helpful!

    Thread Starter hiteshranaut

    (@hiteshranaut)

    hey i used
    https://www.ads-software.com/plugins/dynamic-featured-image/

    this plugin for multi featured images and worked fine !! you can get the title caption also using this !!

    Plugin Author Chris Scott

    (@chrisscott)

    You can do this the same way you’d get the title and caption for any attachment but replace the attachment ID w/the thumbnail ID. e.g. (assumes you are in the loop and your thumbnail id is secondary-image):

    $post_thumbnail_id = MultiPostThumbnails::get_post_thumbnail_id( get_post_type(), 'secondary-image', get_queried_object_id() );
    $post_thumbnail_post = get_post( $post_thumbnail_id );
    $caption = trim( strip_tags( $post_thumbnail_post->post_excerpt ) );
    $title = get_the_title( $post_thumbnail_post );
    echo esc_html( $caption );
    echo esc_html( $title );

    Thread Starter hiteshranaut

    (@hiteshranaut)

    hey thanks !!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to get the Title and Caption for secondary-image’ is closed to new replies.