PHP Code to Insert ad unit if a post having a defined number of words in WordPress
Put this code in your desired page.php or single.php etc. to Insert ad unit if a post has a defined number of words in WordPress
1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php $content = get_the_content(); $word_count = str_word_count($content); // Insert AdSense ad after 200 words if ($word_count > 10) { echo 'yyy'; } // Output the rest of the content echo $content; ?> |