PHP code example of keesiemeijer / insert-content

1. Go to this page and download the library: Download keesiemeijer/insert-content library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

keesiemeijer / insert-content example snippets



 keesiemeijer\Insert_Content\insert_content( $content, $insert_content, $args ); 

$args = array(
	'parent_element_id' => '',
	'insert_element'   => 'p',
	'insert_after_p'   => '',
	'insert_every_p'   => '',
	'insert_if_no_p'   => true,
	'top_level_p_only' => true,
);


$args = array(
	'insert_after_p' => 2, // Insert after the second paragraph
);

// Content you want to insert (without the parent element HTML tag)
$insert_content = 'I was inserted after the <strong>second</strong> paragraph';

echo keesiemeijer\Insert_Content\insert_content( $content, $insert_content, $args );


$args = array(
	'parent_element_id' => 'specific-id'
	'insert_after_p'    => 2, // Insert after the second paragraph
);

// Content you want to insert (without the parent element HTML tag)
$insert_content = 'I was inserted after the <strong>second</strong> paragraph inside the targeted element';

echo keesiemeijer\Insert_Content\insert_content( $content, $insert_content, $args );