Get help. Give help. A Web Design and Development Community.
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.
You can add title to the featured image:
< ?php echo get_the_post_thumbnail($id, '', array( 'title' => '#post-id' )); ?>
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?
You must be logged in to reply to this topic.