Documentation

How to use and configure the Intagrate WordPress plugin

Split an Instagram Caption Into a Post Title and Content

Avatar
Written by Iain
Last updated 05 Dec 2026

To split an Instagram caption into a post title and content, Intagrate Pro needs two small template tags of your own: one for the caption’s first line, which becomes the post title, and one for everything after it, which becomes the content. This page gives you the code and the account settings to go with it.

By default an account uses the whole caption, %%caption%%, as the title, and the post content often repeats it. Many people write captions with a headline on the first line, and that’s what this splits on.

Without code: a shorter title

If you only want shorter titles, set Title Length Type to Words and Title Length Limit to, say, 10, in Intagrate > Settings. Every title is then the caption’s first 10 words, and the content can still show the whole caption with %%caption-no-tags%%. That cuts mid-sentence, though. For a clean split, add the tags below.

Add two template tags

This code, which needs Intagrate Pro 1.13.0 or newer, adds two tags:

  • %%caption-first-line%%: the caption up to its first line break
  • %%caption-after-first-line%%: the rest of the caption, without hashtags
add_filter( 'igp_add_template_tags', function ( $tags, $media ) {
    $caption = $media ? str_replace( "\r", '', (string) $media->caption ) : '';
    $lines   = explode( "\n", trim( $caption ), 2 );
    $rest    = isset( $lines[1] ) ? $lines[1] : '';

    // Drop hashtags from the rest
    $rest = trim( preg_replace( '/(^|\s)#[^\s#]+/u', '$1', $rest ) );

    $tags[] = array(
        'name'  => 'caption-first-line',
        'desc'  => 'The first line of the caption.',
        'value' => sanitize_text_field( $lines[0] ),
    );
    $tags[] = array(
        'name'  => 'caption-after-first-line',
        'desc'  => 'The caption after its first line, without hashtags.',
        'value' => wpautop( esc_html( $rest ) ),
    );

    return $tags;
}, 10, 2 );

Add it with a code snippets plugin, or in a small plugin of your own, rather than your theme’s functions.php, so a theme update doesn’t remove it. The two tags then appear in the account’s Template Tags box with the built-in ones.

Use them in the account

Edit the account in Intagrate > All Accounts:

  1. In the title box at the top, replace %%caption%% with %%caption-first-line%%.
  2. In the content, put %%caption-after-first-line%% where the text should go, for example under the image:
<img alt="%%caption-no-tags-escaped%%" src="%%image%%" class="%%instagram-media-type%% %%image-class%%">
%%caption-after-first-line%%
  1. Click Update.

A caption like this:

Fresh sourdough, out of the oven

We bake three batches every morning, so come early for the first loaves. #bakery #sourdough

becomes a post titled “Fresh sourdough, out of the oven”, with “We bake three batches every morning, so come early for the first loaves.” in the content.

A caption with only one line becomes the title, and %%caption-after-first-line%% is empty.

The tags work in the excerpt, custom fields and the text fields of the ACF Fields box too. Posts Intagrate has already created don’t change: the split applies from then on.

Split on the first sentence instead

If you don’t use line breaks in captions, split on the first full stop, question mark or exclamation mark. Replace the two $lines lines above with:

    $lines   = preg_split( '/(?<=[.!?])\s+/u', trim( $caption ), 2 );

The tag names stay the same, though they now hold the first sentence and the rest.

The older way

Earlier versions of this page filtered %%caption%% and %%caption-no-tags%% themselves with igp_template_caption and igp_template_caption_no_tags. That still works, but it changes those tags everywhere they’re used: titles, content, excerpts, custom fields and saved image captions. Separate tags don’t, so if you set up the older code, consider switching.

Template tags lists the built-in tags, and developer hooks covers igp_add_template_tags and Intagrate’s other filters.

  • 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