Skip to content

Instantly share code, notes, and snippets.

@kachi
Created June 27, 2012 12:38
Show Gist options
  • Save kachi/3003835 to your computer and use it in GitHub Desktop.
Save kachi/3003835 to your computer and use it in GitHub Desktop.
<?php
add_filter('the_content', 'ads_more_tag');
function ads_more_tag($text) {
if( is_single() ) :
$ads_text = '<span>
//アドセンスのコード
</span>';
$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;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment