Inserts media.net advertisement after a few paragraphs

Advertising is part of modern day life. It comes by choice for web administrators. Sometimes, many bloggers tend not to use such advertisements for considerable period of time. After getting certain views then they move towards it. It is the choice and wish of the web master. Personally, I fond of inserting advertisements on websites as it makes website looks beautiful and the readers with ad blocking options switched off tend to find some really good information through these. I began to use the media.net ads on my present site after my application to them have been successfully reviewed. Still-t0-date, though I have moderate earnings but the primary focus on these advertisement for the time beings is to find my money is wordpress hosting packages and wordpress domain packages.

Even till this day, I have been experimenting for about advertisements for placements and continue to do that still the date I got handsome results. My first emphasis on my site is to present users with information on variety of subjects and educate and convey them my opinions on these subjects and I expect the advertisements that has been on the roll in it should provide some additional information so that ultimately that should present users with handsome information in addition to article. That is the reason why i want to place on advertisement inside article but still this day not being able to do this until I have done this.

It is not just a simple idea as the standard WordPress procedure is to bring out the article from its database and loads on web browser and to put ads inside of it remains a good amount of tactics and this procedure also changes from theme to theme but this time I got the information from internet and wish to write it down so that when ever I would change the theme of website for sure go back to this article to know what are the procedure to insert ads inside content. WordPress server connects with its database with just single line and then inserting something in the middle of this seems a very difficult idea that is why most of the articles on this subject to the internet does not seem to work in the correct manner.

Generally, while editing any of these files of WordPress I would prefer to go with cPanel hosting side so that after review of coding if something goes wrong then I could reach out to and correct those codes immediately. Instead of theme editor of WordPress I prefer to go from ‘file browser’ of cPanel. After logging into cPanel reached to ‘File Manager’ and open it.

FILE MANAGER

Then move to ‘wp-content’ and open it.

wp-content
wp-content

Then move to ‘themes’ and open it.

themes
themes

It will show you the installed theme and the default themes that installed with WordPress. Click on the installed Theme. In my case it is ‘grandstand’.

grandstand
grandstand

It is important to open the activated theme that has been activated by you for your blog on word press administration segment.

It would then show the php and other files and folders that have been inside the theme. Just scroll on to it to find out ‘single.php’ and double click on it to back up the files, in case something wrong happens while putting the code, we could upload that files and replace the wrong coded file.

singledotphp

Then, just select ‘single.php’ and the top menu click on ‘code editior’.

code editor

It would show you a ‘Code Editor’ dialogue box.

code editor dialogue box

Then click on ‘Edit’ and it would open ‘single.php’ on a new page of web browser window. Go to its 62 number entry, which is ‘<?php the_content(); ?>’ or control ‘F’ while the file is open on browser and paste this code to search for this line on your theme, and then replace that with the below mentioned code.

Code starts here--------------------
<?php
$show_after_p = 2;
$content = apply_filters('the_content', $post->post_content);
if(substr_count($content, '<p>') > $show_after_p)
{
 $contents = explode("</p>", $content);
 $p_count = 1;
 foreach($contents as $content)
 {
 echo $content;

if($p_count == $show_after_p)
 {
 ?>
 YOUR MEDIA.NET code GOES HERE
 <?php
 }
 echo "</p>";
 $p_count++;
 }
}
?>

Code ends here------------------------------------

This is not a complex code. At the second line of the code,’ $show_after_p = 2’ and 2 is the advertisement to be shown after second paragraph of article. If you want to make it to third or fourth or so on then change that to number 3 or 4 or so on. Then move to the line where it is written as ‘ YOUR MEDIA.NET code GOES HERE’ and paste you adsense or media.net code there. If you have SSL site or normal site, do this in according to the code. Then after doing this copy entire code and then replace it with ‘’. Do remember to replace ‘’ with the above code. Then click on ‘Save Changes’ and you are done.

Save changes

If you have followed all of these steps correctly which are the most basic ones then for sure you would be seeing advertisements on the after precise paragraphs after articles. Do open the individual article on your favorite web browser and without ad block and check it back and for sure if all the above steps have been performed correctly you would be for sure see advertisements inside precise paragraph.

There has been many advertisement plugins which you can do it normally without wasting any of yours time but still it is better to use code instead of plugin as this could result in faster website loading time as well as you would have excellent control over entire code here. With this as web master for one also learns immensely so that with due course of time with acquired accumulated knowledge one could slowly build another form of stronger management of ideas while playing with php, css and javascript codes. Also after upgrading my site to flexible SSL, I have found that the most http media.net codes are not working.

I contacted my account manager and they responded swiftly and provide. Me with https codes but surprisingly that does not work through wordpress admin and text widget function. Then, I decided to put these codes into cPanel and all now works and in this case the ad rotating plugins would be vague and for this it is important to know the tits and bits of installing the codes into theme files so that everything should be nice and good and every control should be with yours hands instead of depending too much on plugins.

*A few days ago, I read a post on doitwithwp which discussed the idea of inserting ads after a few paragraph. I’d never heard of this before, but I was intrigued, so I read on.*

About Mohan Manohar Mekap

Mohan Manohar is a blogger from India who founded Ittech back in 2007. He is passionate about all things tech and knows the Internet and computers like the back of his hand.

Leave a Reply

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

IndiChange - Harnessing the collective power of blogging to fight evil.