Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
mark007 Posted March 2, 2018 Posted March 2, 2018 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!
mark007 Posted March 3, 2018 Author Posted March 3, 2018 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');
MeMaBlue Posted March 4, 2018 Posted March 4, 2018 @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)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.