How to Insert Code after More Tag within WordPress Post Page

This Simple tutorial will show you how to add/insert code or advertisement etc. right after the tag, but within the post page. For doing this, all we need is to add some piece of code in your theme’s Functions.php


This code will replace the with your ad added above in my_ad() Function

add_filter('the_content', 'adds_block');

function adds_block($content){
 if (is_single())
 global $post;
$thePostID = $post->ID; // getting the post ID
$new_insert = '<span id="more-' .$thePostID.'"></span>' ;
 return str_replace($new_insert, my_ad(), $content);
function my_ad(){
 return ' Your Ad Code '; // What you want to display in place of the more tag. can be a custom code, advertisement etc.

Share the love

Leave a Comment

Please keep in mind that comments are moderated and rel="nofollow" is in use. You can use [code][/code] if you want to write codes. Don't spam us :) Thanks!