Strattic Developers by Elementor

Publishing with StoryChief

StoryChief.com is a “leading content marketing platform that makes sure your brand gets the attention it deserves” (according to their website. It allows you to publish and schedule posts, as well as post automatically to different social media channels.

We’ve got basic instructions for getting set up here.

However, you may wish to customize the functionality a bit more… 🤓

Below is some boiler plate code that will help you run a Quick pubish to static, as well as customize publish parameters.

Please follow the comments for instructions.

If you have questions about where to find YOUR_SITE_ID, YOUR_DISTRIBUTION_ID, and your API_KEY, please reach out to our support.

<?php

// StoryChief customizations
add_filter( 'storychief_publish_permalink', function ( $permalink, $post_id ) {

    // Change this when on Live or Preview (uncomment one).
	// return strattic()->publish->replace_published_url( $permalink, strattic()::PREVIEW_DISTRIBUTION_TYPE );
	// return strattic()->publish->replace_published_url( $permalink, strattic()::LIVE_DISTRIBUTION_TYPE );
}, 99, 2 );

// After the publish action via StoryChief plugin, run a quick publish.
add_action('storychief_after_publish_action', function ( $story ) {
	set_transient( 'strattic_story_chief_publish', 'yes' );
	$url  = 'https://REACH_OUT_TO_STRATTIC_SUPPORT_FOR_YOUR_CUSTOM_URL/...';
	$args = [
		'headers' => [
			'Authorization' => 'API_KEY',
			'Content-Type'  => 'application/json',
		],
		'body'      => wp_json_encode( [
			'siteDistributionId' => YOUR_DISTRIBUTION_ID,
			'publishType'        => 'quick',
		] )
	];

	$result = wp_remote_post( $url, $args );
});


// If this is publish from StoryChief, just publish the Post post type.
add_filter( 'strattic_post_types', function ( $post_types ) {
	if ( get_transient( 'strattic_story_chief_publish' ) && get_transient( 'strattic-publish-type' ) === 'quick' ) {
		return ['post'];
	}

	return $post_types;
}, 99 );

// Delete the transient after quick publish is completed.
add_action( 'strattic_publish_completed', function () {
	delete_transient( 'strattic_story_chief_publish' );
}, 99 );
Cyber Monday 20% Off
days
hr
min
sec