How to place ads after the first paragraph in $dlm_download->content
-
what am doing wrong here?, I edited the template but add_filter wont display the content
<?php
//Insert ads after first paragraph of content.
add_filter( ‘$dlm_download->the_content’, ‘prefix_insert_post_ads’ );
function prefix_insert_post_ads( $content ) {
$ad_code = ‘<div>Ads code goes here</div>’;
return prefix_insert_after_paragraph( $ad_code, 1, $content );
return $content;
}function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
$closing_p = ‘</p>’;
$paragraphs = explode( $closing_p, $content );
foreach ($paragraphs as $index => $paragraph) {if ( trim( $paragraph ) ) {
$paragraphs[$index] .= $closing_p;
}if ( $paragraph_id == $index + 1 ) {
$paragraphs[$index] .= $insertion;
}
}return implode( ”, $paragraphs );
} ?>
- The topic ‘How to place ads after the first paragraph in $dlm_download->content’ is closed to new replies.