create your own

Step by Step Guide to Installing a WordPress Blog that can be Monitized using Adsense

76
rate or flag this page

By leckyt

Monetize WordPress Blogs

There are many ways to earn money from a WordPress blog, but by far the easiest is to use AdSense to promote sites, and earn money through clicks away from the blog. Thus, the blog becomes a traffic attractor, giving value to the visitor, whilst tempting them away to other sites once they've gleaned the information that they came for in the first place.

(The first step is to sign up for a Google AdSense account, at AdSense.Google.com - and take a quick look at how to set it up.)



What do you Need?

There are a few pre-requisites that have to be satisfied before a WordPress Blog can be built.

  • Host with PHP & MySQL : to host the WordPresscontent management system used to deliver the blog (although, WordPress.com will host it for free - see the caveat below);
  • FTP Client : to upload and download files;
  • Text Editor : to edit files if the internet connection is not stable enough to edit the WordPress themes inline.

The reason for all of the above is simple - the WordPress.com site does not let the user edit their blog templates unless they pay a fee. If this is acceptable, then the reader can skip the Installtion Step and move right down to the AdSense specific points.

Installing

Installing WordPress on a hosted site is easy. If you already have it installed, then you can skip to the AdSense specific part of this guide. For those choosing to run a remote WordPress blog, and pay the modest sum required by WordPress.com to have templates that are updatable, then this step can also be skipped.

Automatic Install

This is the easiest method, by far. Simply log into the hosts cPanel account, locate the 'Fantastico' application manager, and somewhere in the possible packages that can be installed, you will find WordPress.

The install process with set up a database, and ask a number of inmportant questions. When it is over, do not forget to have it send an email with the installation settings inside - they are necessary for monetizing the blog.

Manual Install

The manual install is not very difficult. The first step is to go to WordPress.org and download the latest ZIP archive containing all the scripts.

Then, use phpMyAdmin to set up a new MySQL database, and a user with all the rights (add, delete, modify, amend, alter etc.).

Next, unzip the archive of scripts into the folder where the blog should go. This could be the root, but it is probably a good idea to keep it separate.

Then, find the config-wp-sample.php script and rename it to config-wp.php. Download it to the local machine, and edit the database information so that it matches the database that was set up.

Upload the script, replacing the old one.

Finally, go to the URL : http://your-url.com/wp-folder/wp-admin/install.php

From here, the WordPress Blog will be automatically installed. Once the script finishes, the Blog is ready to be monetized.

WordPress Layout

In order to add the AdSense code in the appropriate place, it is necessary to know a few things about the way that WordPress is laid out. A WordPress Blog consists of four principle parts that need to be edited in order to correctly place AdSense monitization code:

  • styles.css (Stylesheet where all the styles are stored)
  • index.php (Main Index page)
  • sidebar.php (Sidebar for all pages)
  • post.php (Single Post)

The main point for editing the code that manages the look and feel is in the Theme Editor. To get to the Theme Editor, simply go to the main page of the newly installed blog, and click the login link. It should be on the right hand side, right at the bottom.

From here, just select 'Presentation' from the main menu bar at the top of the page, and then 'Theme Editor' from the sub menu. The screen is divided into a main content editing area, and a set of options that give access to the theme files, down the right hand side.

Of these, most of the work is done in the Main Index Template (index.php page). It consists of four main rendering units - header, main content, sidebar, and footer.

These are filled out by .php scripts, except the main content, which is filled in a loop of code in the index.php page. We will look at how to introduce AdSense code in the main content area and sidebars of the index.php (Main Index) and also the individual blog entry pages.

WordPress and AdSense

You can put the AdSense JavaScript code supplied by Google in the index.php page by simple cut and paste from the AdSense site. It is normal to use either a horizontal or vertical advert block depending on placement.

The first step is to create a <div class=adsense_block> in the Stylesheet (style.php) accessible from the list of files. The minimum should be to use style such as: text-align: center; display: block borders: none. This creates a centerd block, with no borders.

Once this is done, AdSense code can be insterted in the main index.php page (selecting Main Index Template). There are two possible places for the code:

  • Inside the WordPress loop
  • Outside the WordPress loop

If the code is inside the WordPress loop, then there will be one set of AdSense adverts per post summary. If it is placed outside, either before, or after, then there will be one AdSense block for the whole page.

Before inserting the code, it should be prepared. Copy and paste the JavaScript that AdSense creates for use in content into a text editor. Next, add the HTML for the style that was created in the previous step - this will mean adding <div class="adsense_block"> above and </div> below the code; before the <script> tag, and after the </script> tag.

Once this has been done, the whole block can be copied and pasted into the Theme Editor in the index.php file (Main Index Template option).

Outside the Loop (Above)

Look for the line of code that starts <?php while (have_posts())... This is the start of the WordPress loop. If the AdSense div block is inserted above this line, then it will appear once for the whole page - at the top.

Inside the Loop

Again, look for the <?php while (have_posts())... line. Following down the page, the loop is closed with a line <?php endwhile; ?> This is the end of the loop - anything that appears between the <?php while line and this one will be reproduced once per blog summary entry on the main page.

So, insert the AdSense div block just above the <?php endwhile; ?> line.

Outside the Loop (Below)

Given that the loop is closed with the <?php endwhile; ?> line, if the code is placed just after it, then it will appear once for the whole page - but at the end of the post summaries. Be aware that readers might not make it this far down, because it will be below the fold.

Obviously, the AdSense div block could be placed in all three locations. The reader will have to use their discretion in choosing appropriate code placement.

AdSense Monetization of WordPress Sidebar

The index.php (Main Index) only shows snippets of each blog, so to have AdSense monetization code appear on multiple pages, a good place to put it might be in the sidebar.

To do this, the reader might want to change the layout of the AdSense block so that it is vertical rather than horizontal, matching the layout o fthe sidebar.

The code is placed in the sidebar.php file (Sidebar from the Theme Editor menu), and can be placed in multiple locations. Using the same AdSense JavaScript div block as prepared in the previous step, but with the AdSense for content JavaScript code that matches the layout of the sidebar, the same copy and paste approach can be used to insert it in the sidebar.php page.

To locate the code above the search box, simple look for the code <?php includ... and check that it is 'including' the searchform.php file. This is the search box - the AdSense div block can be placed above or below it, depending on individual taste.

AdSense Monetization of WordPress Blogs FAQ

If you have a question, please post it in the comments section below, and I will add it to this FAQ.FAQ

Q: Can I monetize a WordPress blog hosted by WordPress.com?

A: Not easily, because you can't change the layouts to add AdSense code. However, it is possible to pay a small fee and allow changes to the code to be displayed on the blog.

Q: Can I host a WordPress blog without PHP support?

A: No. PHP is required for WordPress blogs.

Q: Can I host a WordPress blog without a database?

A: No. MySQL is required for WordPress.

Print   —   Rate it:  up  down  flag this hub

Please Post FAQ Questions and/or Comments Here

RSS for comments on this Hub

Ivy  says:
2 years ago

Hi there! I do have one teeny question...

I want a 160x600 ad in my sidebar, but I want it to be viewable only when a reader clicks on a single post. I realise I'd have to place the adsense code within the loop like this;

<?php if (is_single()) { echo ' Your adsense code goes here ';} ?>

But none of my folders have that particular loop. Do you know how I could maybe add the loop..? Or is there an easier way? Thank you in advance! :)

Yeah.  says:
2 months ago

Just in case someone else comes across this, I'll recommend using Adsense Integrator plugin for putting adsense in your wordpress blog. You can use it to easily put ads in a single post or just pages, or just categories. Pretty much anywhere you like.

As far as I know, it doesn't provide the function to put adsense in the sidebar or top of the page, at least, I haven't been able to get it to do that.

Submit a Comment
Members and Guests

Sign in or sign up and post using a hubpages account.


optional


  • No HTML is allowed in comments, but URLs will be hyperlinked
  • Comments are not for promoting your hubs or other sites

working