Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted March 2, 20187 yr Hi, I would like to place Adsense in the first post and after first paragraph of the post. Right now I use this code in post template: {{if $_REQUEST['ad_inside_first_post'] = !isset($_REQUEST['ad_inside_first_post']) ? 1 : 0}} {advertisement="....."} {{endif}} Is there a way to show advertisement after first paragraph in the first post? Many thanks in advance!
March 3, 20187 yr Author The solution in Wordpress is like this: It would be great to have it also for IPS function insert_ad_block( $text ) { if ( is_single() ) : $ads_text = 'ERASE-THIS-PART-AND-PASTE-IN-YOUR-ADSENSE-CODE-HERE'; $split_by = "\n"; $insert_after = 1; //number of paragraphs // make array of paragraphs $paragraphs = explode( $split_by, $text); // if array elements are less than $insert_after set the insert point at the end $len = count( $paragraphs ); if ( $len < $insert_after ) $insert_after = $len; // insert $ads_text into the array at the specified point array_splice( $paragraphs, $insert_after, 0, $ads_text ); // loop through array and build string for output foreach( $paragraphs as $paragraph ) { $new_text .= $paragraph; } return $new_text; endif; return $text; } add_filter('the_content', 'insert_ad_block');
March 4, 20187 yr @newbie LAC personally i dont know, but I am tagging NewbieLac because he has helped me with these things , i also have plugins from him - there is a plugin he has created that will make it possible to put an ad ANYWHERE you want (called enhanced ads)
Archived
This topic is now archived and is closed to further replies.