Show multiple ads Between post using function codes
-
For multiple ads on post
I have implemented first code and it perfectly work. But iam not good at coding so can you tell me how to show multiple ads? This second code how to implement it properly can you help me with it?
Also for multiple ads do i need to create second in article ads code? Or i can use the same ads code twice?//Insert ads after third paragraph of post content. add_filter( 'the_content', 'insert_post_ads' ); function insert_post_ads( $content ) { $ad_code = '<div>Insert your Ads code here</div>'; if ( is_single() && ! is_admin() ) { return prefix_insert_after_paragraph( $ad_code, 3, $content ); } return $content; } // Parent Function 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 ); }
And this code:
2 3 4 5 6 7 8 9 10 11 $first_ad_code = ‘Ads code goes here’; $second_ad_code = $first_ad_code; if ( is_single() && ! is_admin() ) { $content = prefix_insert_after_paragraph( $first_ad_code, 3, $content ); $content = prefix_insert_after_paragraph( $second_ad_code, 6, $content ); return $content; } return $content; }
I can’t merge this codes. Please help.
The page I need help with: [log in to see the link]
- The topic ‘Show multiple ads Between post using function codes’ is closed to new replies.