• Resolved defyogo

    (@defyogo)


    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 );
    } ?>

    • This topic was modified 7 years ago by defyogo.
    • This topic was modified 7 years ago by defyogo.
Viewing 1 replies (of 1 total)
  • Hey,

    What you’re describing is considered custom development. Unfortunately we don’t do any custom development work. If you are unable to do the custom development I recommend you hire a developer to do these customization for you.

    Kind Regards,

    Barry Kooij

Viewing 1 replies (of 1 total)
  • The topic ‘How to place ads after the first paragraph in $dlm_download->content’ is closed to new replies.