Add code below read more tags in the content
-
Hi Dear :
I want to add code such as Ads image below <!–more–> or read more tags in the content.
I search this code copy to my desktop and mobile function.php file.
That can work well in these two platform except “AMP for WP – Accelerated Mobile Pages” plugin. It can’t work and shows error.
I use “Design Theme” and copy this code to Design Theme function.php.
I don’t know how to rewrite this code and fix it.
Can you help me? Thanks.
=================== code ===================
add_filter(‘the_content’, ‘adsense_adder_at_more_tag’);
function adsense_adder_at_more_tag($text) {
if( is_single()) :
$ads_text = ‘My code’;
$pos1 = strpos($text, ‘<span id=”more-‘);
$pos2 = strpos($text, ‘</span>’, $pos1);
$text1 = substr($text, 0, $pos2);
$text2 = substr($text, $pos2);
$text = $text1 . $ads_text . $text2;
endif;
return $text;
}
=================== code ===================
- The topic ‘Add code below read more tags in the content’ is closed to new replies.