Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Add Post ID to Featured Image

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #42048
    jonedwards
    Participant

    Hi

    I’m creating a featured post slider for WordPress. In order to get an HTML caption to display, I need to set the title of the featured image to the post’s ID (title=”#post-id”). I’m thinkin something on the lines of…

    < ?php the_post_thumbnail('article-banner',array( 'class' => “”, ‘title’ => ” #.get_the_ID(); “)); ? >

    …but I’m not sure if that’ll work and it seems a little contrived. The output that I’m ultimately looking for needs to be:

    < img src="media/featured-image.jpg" alt="" title="#post-id" / >

    Any help would be appreciated. Thanks in advance.

    #121255
    realife
    Member

    You can add title to the featured image:


    '#post-id' )); ?>

    #121336
    jonedwards
    Participant

    Hey, @realife, thanks. Could you explain how this would pull the post’s ID into the title tag? At face value, this doesn’t look like it would work?

    Thanks

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.