,

How to insert Dynamic Connector blocks in bulk

smallplugins Avatar

·

We recommend inserting Dynamic Connector block(s) manually so you can tailor the placement of your content manually. However, the fastest way to get up-and-running with this plugin is to have this block inserted site-wide. There are a few ways you might go about this:

  1. Use a block/site editor theme, where you can edit your theme’s site layout to include this block at the top or bottom of all posts.
  2. Use our FREE plugin, Automatic Block Inserter! Here’s a tutorial that shares specifically how to insert a generic site-wide email subscribe form.
  3. Use a plugin, like Insert Blocks Before or After Posts Content, as a stop-gap solution to achieve the same result.
  4. Write some custom code to a reusable block (holding your Dynamic Connector block…) within your post content (using some formula, like after the first paragraph).
add_filter( 'the_content', 'sp_bulk_insert_block' );
function sp_bulk_insert_block ( $content ) {
	
	if ( is_single() ) {

		$pattern = '#(.*?<\/p>)(.*)#s'; // after first paragraph
		$replacement = '$1' . do_blocks( get_post( REUSABLE_BLOCK_ID )->post_content ); . '$2';
		$subject = $content;

		$content = preg_replace( $pattern, $replacement, $subject );
		
	}

	return $content;

}

Leave a Reply

Your email address will not be published. Required fields are marked *