Loading

Adding ADS between WordPress Post Contents

Post Content
Adding ADS between Wordpress Post Content image

Adding ADS between WordPress Post Contents

Adding ADS between post contents in WordPress without using any plugins.

Most websites owners need to put their advertisements in different places of their own websites.

They need to put them between post content for visitors.

Follow the coming steps to do this:

  1. Open your theme folder.
  2. Open the file named “functions.php” into your code editor.
  3. Copy & paste the following function code before the closing php tag ?>:
    function adsIntoPostContent($content){
    if(is_single()){
    $content_block = explode('<p>',$content);
    if(!empty($content_block[2])) {
    $content_block[2] .= 'insert_the_AD_code_here';
    }
    for($i=1;$i<count($content_block);$i++) {
    $content_block[$i] = '<p>'.$content_block[$i];
    }
    $content = implode('',$content_block);
    }
    return $content;
    }
  4. Replace the text string (( insert_the_AD_code_here )) into the function by the actual ad code.
  5. Copy  & paste the following filter directly after the function:
    add_filter('the_content', 'adsIntoPostContent');
  6. Save changes.
  7. Visit any post of your website to see your AD into your post.

Enjoy your advertisements ;).

Write a comment

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.