@charset "UTF-8";function adsense_before_h2($the_content){$ad=<<< EOF [ad] EOF;if (is_single()){//投稿ページ $tag='/^<h2.*?>.+?<\/h2>$/im';//h2見出しのパターン if (preg_match_all($tag,$the_content,$h2gets)){if ($h2gets[0]){$count=0;foreach ($h2gets[0] as $h2get){$count++;//少なくても1番目は目次と被るので飛ばす(今は偶数番目仕様) if ($count%2==0){if ($h2get){$the_content=str_replace($h2get,$ad.$h2get,$the_content)}}}}}}return $the_content;}add_filter('the_content','adsense_before_h2');