Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【WordPress】WordPress 用 AdSenseプラグインにプレースメントコードを続きを読むの直後に挿入する方法
<?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