Documentation

How to use and configure the Intagrate WordPress plugin

Instagram Caption Splitting

Avatar
Written by Iain
Last updated 11 Dec 2019

Converting an Instagram image to a WordPress post can be tricky when it comes to the caption on Instagram, as sometimes you might want some parts of the caption to become the post title, and other parts to become the post body.

Using the built in template tags you can tell the plugin where to use the caption, but if you want to make the caption be split between the title and body you will need to do a little extra work.

Luckily all the template tags are filterable so we can do whatever we want to the value they return. If you are new to filters in WordPress check out this guide.

Format Your Captions

Before we dive into the code, you need to make sure the captions you add to your images on Instagram have some form of break that we can use, for example all of the caption up to the break (the first period or special character etc) will become the post title, and everything after will be the post body text.

In this example, I will use the first period in the caption, like in this Instagram image:

Configure the Code

We need to use a filter to change two of the caption template tags to output the two halves of the Instagram image caption.


<?php
add_filter( 'igp_template_caption', 'my_igp_caption_post_title' );
function my_igp_caption_post_title( $caption ) {
	if ( is_null( $caption ) ) {
		return $caption;
	}

	$parts = explode( '.', $caption );

	return $parts[0];
}

add_filter( 'igp_template_caption_no_tags', 'my_igp_caption_post_content' );
function my_igp_caption_post_content( $caption_no_tags ) {
	if ( is_null( $caption_no_tags ) ) {
		return $caption_no_tags;
	}

	$parts = explode( '.', $caption_no_tags );

	if ( 1 === count( $parts ) ) {
		return $caption_no_tags;
	}

	array_shift( $parts );

	return implode( '.', $parts );
}

Where shall I add the code? Take a look at this guide.

Account Settings

I can then configure my Intagrate account with the post title using the %%caption%% tag, and the post content with the image and the %%caption-no-tags%% tag.

Split Instagram caption to post title and content

The End Result

When the plugin creates the post this will be the result:

Post with split caption

There isn’t a way to split on line breaks at the moment, but that will be introduced in a future version of the plugin.

  • Contents
  • Intagrate Lite
    There is a community support forum for the free version of the plugin available. Community Support
  • Something else?
    Can’t find what you are looking for in the documentation?
Open a Suport Ticket

Let's get you started

Start publishing your Instagram media to your site today