Created
February 19, 2016 00:36
-
-
Save kurozumi/0150fcaaded3732781cb to your computer and use it in GitHub Desktop.
【WordPress】WordPress 用 AdSenseプラグインにプレースメントコードを続きを読むの直後に挿入する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('the_content', function($content){ | |
$post_id = get_the_ID(); | |
$adsense = "<ins id=\"more-{$post_id}\" style=\"display: none;\" class=\"adsbygoogle-placeholder\"></ins>"; | |
return preg_replace('/(<span id="more-[0-9]+">)(<\/span>)/', "$1{$adsense}$2", $content); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment