Changing the automated captions

In the book “Don’t make me think” by Steve Krug, there’s an explanation about the fact that humans are quite likely to scan an article instead of reading it.

While scanning your article the parts that stand out are the ones that are more unique. That includes images and captions, as captions are normally in a different style.

Unique watermelon bicycle
Photo by Cristina Gottardi on Unsplash

Unique captions

You should aim to be unique as much as possible, as unique stands out. To support that, we are allowing an easy way to customize the captions in WordPress.

There is a filter available named suggestively: stockpack_caption

This filter allows translating or modifying the format of the caption. The default WordPress caption looks like this (end lines added for readability):

Photo by 
<a href="">
    John Doe
<a href="">

That is the code, here’s how that renders: Photo by Cristina Gottardi on Unsplash

Setting your own caption

If you are not familiar with code, we got you covered. Currently, you need to parse that caption, as the data is not available separately, but in time that might change. Here’s an example:

function change_stockpack_caption_format( $caption, $image ) {
	if ( $caption === '' ) {
		return $caption;
	$chunks = explode( "<", $caption );
	$author= explode( ">", $chunks[1] );

	return "Via <$chunks[3]</a> / $author[1] ";

add_filter( 'stockpack_caption', 'change_stockpack_caption_format', 20, 2 );

This function removed the author URL, and displays only the image URL, while mentioning the author. Since users can easily get the author from the image URL this should be just fine.

Here’s how that renders: Via Unsplash / Cristina Gottardi

Going further

If you have a specific caption format you need for your WordPress website, and you can’t get it working on your own, feel free to reach out. We’d be glad to help.

If you are looking for some tricks to help you stand out with your images check this article: 5 simple image tricks that go a long way in WordPress

3 thoughts on “Changing the automated captions”

  1. Outbound links from an article are a lever to be used for SEO – there is no doubt.
    Outbound links, as well as inbound links (internal and external) help provide context or topical direction to Search Engines about the page level topic AND domain level.

    What I don’t like about the caption field is the automatic insertion of the links.

    Every page on a website having links to the same stock photo website doesn’t provide direction to search engines on topical relevance – it actually dilutes it.

    Therefore the ability to remove all links from the caption is a valuable lever for anyone interested in Search Engine Optimisation.

    Could you share a version of the code snippet that removes all links from the caption?

    • I think removing the link is against the terms for some cases, depends on the website and on the image, so be careful. The links have noreferrer in them, so they shouldn’t impact SEO, but I am not a SEO practitioner, so I might making wrong assumptions. Here’s the snippet above with no link:

      “, $chunks[1] );
      $provider = explode( “>”, $chunks[3] );

      return “Via $provider[1] / $author[1] “;
      add_filter( ‘stockpack_caption’, ‘change_stockpack_caption_format’, 20, 2 );


Leave a Comment