{"id":6145,"date":"2010-08-09T07:00:38","date_gmt":"2010-08-09T12:00:38","guid":{"rendered":"http:\/\/www.casadeblundell.com\/jonathan\/?p=6145"},"modified":"2010-10-23T00:38:01","modified_gmt":"2010-10-23T05:38:01","slug":"adding-links-to-image-captions-in-wordpress","status":"publish","type":"post","link":"http:\/\/casadeblundell.com\/jonathan\/adding-links-to-image-captions-in-wordpress\/","title":{"rendered":"Adding links to image captions in WordPress"},"content":{"rendered":"<p>As you may have noticed, I&#8217;ve recently started adding photo captions to the majority of the photos in my new blog posts.<\/p>\n<p>WordPress has a great feature that lets you add these captions with ease if you&#8217;re using an image you&#8217;ve uploaded to your site\/server.<\/p>\n<figure id=\"attachment_6146\" aria-describedby=\"caption-attachment-6146\" style=\"width: 300px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.casadeblundell.com\/jonathan\/wp-content\/uploads\/wordpress-caption-field-300x313.jpg\" alt=\"\" title=\"Wordpress Caption Field\" width=\"300\" height=\"313\" class=\"size-medium wp-image-6146\" srcset=\"http:\/\/casadeblundell.com\/jonathan\/wp-content\/uploads\/wordpress-caption-field-300x313.jpg 300w, http:\/\/casadeblundell.com\/jonathan\/wp-content\/uploads\/wordpress-caption-field-500x523.jpg 500w, http:\/\/casadeblundell.com\/jonathan\/wp-content\/uploads\/wordpress-caption-field.jpg 686w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-6146\" class=\"wp-caption-text\">Wordpress Caption Field<\/figcaption><\/figure>\n<p>Simply fill in the caption field with the information you&#8217;d like to share (i.e. Rick Rocks out | Photo by Jonathan Blundell) and depending on how your WordPress theme is styled, your results will look something like this:<\/p>\n<p><figure id=\"attachment_6130\" aria-describedby=\"caption-attachment-6130\" style=\"width: 300px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.casadeblundell.com\/jonathan\/wp-content\/uploads\/arcade-fire-300x300.jpg\" alt=\"\" title=\"Arcade Fire - The Suburbs\" width=\"300\" height=\"300\" class=\"size-medium wp-image-6130\" srcset=\"http:\/\/casadeblundell.com\/jonathan\/wp-content\/uploads\/arcade-fire-300x300.jpg 300w, http:\/\/casadeblundell.com\/jonathan\/wp-content\/uploads\/arcade-fire-150x150.jpg 150w, http:\/\/casadeblundell.com\/jonathan\/wp-content\/uploads\/arcade-fire.jpg 500w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-6130\" class=\"wp-caption-text\">Arcade Fire - The Suburbs<\/figcaption><\/figure><br \/>\n<!--more--><\/p>\n<h3>But what if you want to want to add a link to your image caption?<\/h3>\n<p>With some photos released via Creative Commons, <a href=\"http:\/\/www.casadeblundell.com\/jonathan\/reflections\/the-feather-pillow\/#comment-66133787\">photographers like you to link to a particular site<\/a> if you use their photo.<\/p>\n<p>Simply adding the URL to the caption is nice, but it doesn&#8217;t actually link readers back to the site (kinda defeating the purpose of the license). And if you add the standard HTML code for a link&#8230;<\/p>\n<p><code>&lt;a href=&quot;http:\/\/www.flickr.com\/jdblundell&quot;&gt;<\/code><\/p>\n<p>&#8230;the caption will bust and you&#8217;ll get nothing.<\/p>\n<h3>But there is an easy solution!<\/h3>\n<p>I&#8217;ve found some rather complicated work arounds on the web, dealing with your function.php file and such, but as of WordPress 3.0 (you really should upgrade if you haven&#8217;t) the solution involves changing two characters.<\/p>\n<p>To add a link within your image caption, simply replace the standard double quotation marks (&#8220;) in your hyperlink with a single quotation mark (&#8216;).<\/p>\n<p>The resulting HTML will look like so:<\/p>\n<p><code>&lt;a href=&#039;http:\/\/www.flickr.com\/jdblundell&#039;&gt;<\/code><\/p>\n<p><strong>Super easy!<\/strong><\/p>\n<p>So rather than:<\/p>\n<p><code>Business card cubes | Photo by &lt;a href=&quot;http:\/\/www.jdblundell.com&quot;&gt;Jonathan Blundell&lt;\/a&gt;<\/code><\/p>\n<p>Use this caption:<\/p>\n<p><code>Business card cubes | Photo by &lt;a href=&#039;http:\/\/www.jdblundell.com&#039;&gt;Jonathan Blundell&lt;\/a&gt;<\/code><\/p>\n<p>And you&#8217;ll get these results:<\/p>\n<figure id=\"attachment_6117\" aria-describedby=\"caption-attachment-6117\" style=\"width: 300px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.casadeblundell.com\/jonathan\/wp-content\/uploads\/IMG_20100802_150745-300x400.jpg\" alt=\"\" title=\"Business card cubes\" width=\"300\" height=\"400\" class=\"size-medium wp-image-6117\" srcset=\"http:\/\/casadeblundell.com\/jonathan\/wp-content\/uploads\/IMG_20100802_150745-300x400.jpg 300w, http:\/\/casadeblundell.com\/jonathan\/wp-content\/uploads\/IMG_20100802_150745-500x666.jpg 500w, http:\/\/casadeblundell.com\/jonathan\/wp-content\/uploads\/IMG_20100802_150745.jpg 1536w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-6117\" class=\"wp-caption-text\">Business card cubes | Photo by <a href='http:\/\/www.jdblundell.com' target='_blank'>Jonathan Blundell<\/a><\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>As you may have noticed, I&#8217;ve recently started adding photo captions to the majority of the photos in my new blog posts. WordPress has a great feature that lets you add these captions with ease if you&#8217;re using an image you&#8217;ve uploaded to your site\/server. Simply fill in the caption field with the information you&#8217;d &hellip; <a href=\"http:\/\/casadeblundell.com\/jonathan\/adding-links-to-image-captions-in-wordpress\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Adding links to image captions in WordPress<\/span><\/a><\/p>\n","protected":false},"author":84,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[3708],"tags":[3612,3711,3713,3712,3710,3709,1901,415,1184],"class_list":["post-6145","post","type-post","status-publish","format-standard","hentry","category-wordpress-techno","tag-3-0","tag-captions","tag-html","tag-hyperlink","tag-image","tag-images","tag-links","tag-photo","tag-wordpress"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pEnSo-1B7","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/casadeblundell.com\/jonathan\/wp-json\/wp\/v2\/posts\/6145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/casadeblundell.com\/jonathan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/casadeblundell.com\/jonathan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/casadeblundell.com\/jonathan\/wp-json\/wp\/v2\/users\/84"}],"replies":[{"embeddable":true,"href":"http:\/\/casadeblundell.com\/jonathan\/wp-json\/wp\/v2\/comments?post=6145"}],"version-history":[{"count":0,"href":"http:\/\/casadeblundell.com\/jonathan\/wp-json\/wp\/v2\/posts\/6145\/revisions"}],"wp:attachment":[{"href":"http:\/\/casadeblundell.com\/jonathan\/wp-json\/wp\/v2\/media?parent=6145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/casadeblundell.com\/jonathan\/wp-json\/wp\/v2\/categories?post=6145"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/casadeblundell.com\/jonathan\/wp-json\/wp\/v2\/tags?post=6145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}