1. Code
  2. WordPress

Quick Tip: After the Content - Advertisement

Scroll to top
Read Time: 3 min
This post is part of a series called After the Content.
Quick Tip: After the Content - Author Info

Monetization is a great motivation for writing more content. Unless you make it a burden for your visitors to read the content, nobody's going to complain about your earnings from your blog.

In this post, we're going to see one of the only sections that could directly help us financially: the "Advertisement" section!

"Advertisement" to Pay the Rent (Or Get a Cup of Coffee)

For websites, advertisement widgets are probably the easiest way to earn a few bucks ... or cents.

You should be realistic: Is your website "good enough" to make money from it? It may be frustrating to see earning 10 cents every single day if you can't get people to click your ads. That means you have to get more visitors and that means you have to reach your niche's audience.

My general rule of thumb is this: If the website doesn't seem to make enough money to cover its own expenses (such as the domain and hosting fees and annual subscriptions for themes, plugins or any kind of web services), it's not worthwhile to fill the website with advertisements. You should experiment with it on your website - it would be a long experiment which could take months, but it could make you feel better to offer a "clean" website to your audience without any ads.

Of course, it's not uncommon for your visitors to see a couple of ads before or after the content. As long as it's not annoying and it creates a decent revenue for you, you should include advertisements along with your content. It might even be helpful for the visitor if the advertisement is related to the content.

Creating an "Advertisement" Section

I talked about "making the best of Google AdSense" in my recent article, but you could do something simpler if you want:

function wptuts_simple_ads( $ad_type ) {
	switch ( $ad_type ) {
		case "468x60":
			$ad_code = "<!-- Ad code for a 468x60 advertisement. -->";
		case "300x250":
			$ad_code = "<!-- Ad code for a 300x250 advertisement. -->";
		case "728x90":
			$ad_code = "<!-- Ad code for a 728x90 advertisement. -->";
			$ad_code = "<!-- Ad code for the advertisement when 'ad_type' isn't specified. -->";
	$output = '<div class="wptuts_simple_ad ad-type-' . $ad_type . '">' . $ad_code . '</div>';
	return $output;

Place this piece of code into your theme's functions.php file (or save it as a separate plugin) in order to use it. Don't forget to edit the $ad_code variable values for the cases, though. After that, you can simply use <?php echo wptuts_simple_ads('468x60'); ?> anywhere you want in your theme.

I think advertisements should be after the content instead of before. Here's why: Think about placing a relevant ad to your content and a visitor, Jack, comes to your website to read a post of yours.

  • If you place it after the post, Jack reads the entire post and clicks the ad. Jack is both satisfied with your post and the relevant advertisement. A win-win situation.
  • If you place it before the post, Jack might not read the post. He might click the ad before reading the content and forget all about your website because he's already satisfied with the website the ad carried him to.

In both scenarios, you earn money. But in the second one, time spent on your website is decreased and Jack didn't read your post at all. You get the picture.


Yes, content may be "king" but a lonely king is a weak king, and people might not respect that "king".

What do you think about advertisements? How many is "enough"? Where should they be placed? Share your thoughts with us!

Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.