Wordpress: Custom block for Post
updated:
06.11.2020
function calc_in_single( $content ) {
if( !is_single() )
return $content;
$paragraphAfter = 1; // Number of paragraph
$content = explode ( "</p>", $content );
for ( $i = 0; $i < count ($content)-1; $i ++ ) {
if ( $i == $paragraphAfter ) {
?>
<?php echo do_shortcode( '[post_calculator]' ); ?>
<?php
}
echo $content[ $i ] . "</p>";
}
}
add_filter( 'the_content', 'calc_in_single' );
/* comment line
the_content();
*/
<?php
$paragraphAfter = 1; // Number of paragraph
$content = explode ( "</p>", $content );
for ( $i = 0; $i < count ($content)-1; $i ++ ) {
if ( $i == $paragraphAfter ) {
?>
<?php echo do_shortcode( '[post_calculator]' ); ?>
<?php
}
echo $content[ $i ] . "</p>";
}
// end loop