How To Enqueue JavaScript in Footer of WordPress Theme

If you are looking for something which will help you to load or enqueue the JavaScript in Footer of WordPress theme then this post can help you out.

You know its a good practice to load all of your theme’s CSS (Cascading Style Sheet) in the header while all the JS (JavaScript) in the footer. Some call it the golden rule.

But its true that adding JavaScript to the Theme’s Footer can dramatically help to improve the page speed. Lets see how to do that –

First we will create a function, understand it and then make the necessary changes to make it work.

#1) Creating A Function

Go to your theme’s functions.php file . It can be accessed by browsing through Admin Dashboard > Appearance > Editor > Functions.php. Inside this file add the following piece of code.

#2) Understanding The Function

We have created a function name my_scripts_method. When this function is called, it will execute two statements inside it which are nothing but wp_enqueue_script() functions.

First statement adds myscript1.js file inside the header of your WordPress theme.

While the Second statement adds myscript2.js file inside the footer of your WordPress theme.

Now you can skip to 3rd point if you don’t want additional info –

The wp_enqueue_script() function has 5 parameters which are name, path_to_file, depends_on_which_script, version, header_or_footer.

In first function we have only four parameters and since the last parameter is missing, its assumed false by default. If the last parameter is false then JavaScript will be loaded inside the header. But if the last parameter (5th parameter) is true then JavaScript is loaded in footer.

#3) Modifying The Function

In the code given above, you have to just replace myscript1 and myscript2 with your desired JavaScript file name. Also note that you have to place the file inside the your_theme/js folder.

If your theme name is XYZ then you will have to place or upload JavaScript at –


And of course, save the functions.php file after adding the code.

I hope this helps. For more amazing posts do subscribe to blog feed.

How To Create Monthly Archives Page In WordPress

A monthly archives page can be very useful for blog visitors. In this post i’ll show you how to create monthly archives page in WordPress.

First of all, do you know what is monthly archives? Archives are the records of all your blog posts, so monthly archives is basically a record of all your blog posts which are sorted according to the month in which they are posted.

Creating monthly archives includes steps like creating a page template for WordPress, adding some PHP code in this template, uploading this template to the server and finally setting up the page in WordPress Admin Dashboard. So lets see how to do that –

Note – I am going to perform all these steps on Twenty Eleven WordPress Theme. If you have any problem with any step then feel free to comment on this thread, I will try to help you.

#1 – Find the Text Area Class or Id of your Theme

Th first step is all about finding the id or class of your blog post text area. In this case, we found class=entry-content and we will use it in the next step.

#2 – A Bit Of Coding

Given below is the code to display monthly archives of all blog posts. You can see i am using class=entry-content in this code. So if your text area class is different, you have to replace class=entry-content with your theme’s respective class.

Also you can change header from H2 to H1 or H3 according to your wish.

Just copy the code given above, paste it in a notepad file. Save the file as Archive-Page.php

Then Copy this file or Upload this file inside the WordPress theme folder


In this case i am moving the file inside


and the final target of file will be


#3 – Setting up Archive Page using Admin Dashboard

  • Login to your WordPress Blog.
  • Go in WordPress Administrators Dashboard.
  • Click on Pages > Add new
  • Give Title as Archives
  • And to the right side, Inside Page attributes, you will find –

Create Monthly Archives Page In WordPress

  • Select Archives – Page and Publish the page.
  • Click on View Page Button.

The Archives Page is ready. Check the image below –

archives page wordpress

It might look different in your WordPress theme. But you can stylize and fix it using simple CSS. So i hope this post helps you. And for more awesome stuff, Subscribe to blog feed.

How To Find Class Or ID of Text Area In WordPress Theme

Sometimes you might need to find the class or ID of text area in WordPress Theme for adding new snippets of code inside the text area or for modifying the look of text area.

This is actually very simple and total newbie kind of stuff. But its very helpful for people who want to develop their blog and learn more about WordPress.

With the help of this post you can determine the division of text area. Also you can determine the attributes (i.e class and id) of the division in which your text is placed.

Note – I am performing all the steps given below on Twenty Eleven WordPress Theme. 

  • To find the text area class, Just open any blog post in Google Chrome.
  • Select any Text Content inside the Blog Post.
  • Right Click and hit Inspect Element

division with class entry content twenty eleven theme

In the image above i have selected ‘Welcome to WordPress’ text inside a blog post. Then performed Inspect Element on this text, which makes the developer tools pop up from the bottom.

  • You can see the Paragraph Tag ( <p> </p> ) are inside a division ( <div> )
  • And the division has attribute of class=entry-content.

This might be different for your theme, for example –

  1. id=entry or class=entry
  2. id=post-area or class=post-area
  3. id=content-area or class=content-area

So that’s how you can find class or id of the text area division. And once you have found it, you can use it to develop a custom page template like monthly archives page or category wise archives page, etc.

Next Post – How To Create Monthly Archives Page In WordPress

How To Get Google AdSense Account Approved

If you are wondering how to get Google AdSense account Approved in short time then this is the right post for you.

Many AdSense applications are denied because they simply fail to follow Google Policies.  Getting approved can be very easy task if you follow all Adsense Policies Strictly.

In this post i will share the very basic things which you need to get your AdSense account approved. Some people out there have written so called step by step guides on getting approved for Google AdSense. But trust me there’s no rocket science to Get Approved for Google AdSense.

They say that your Blog should be at least Six Months Old to get approval from Google AdSense. But its not really true. I got my Blog Approved within a month. I will tell you my story of how i got approved to Google Adsense  –

The only thing you require to ‘Get Approved‘ is ‘Be Original

I purchased a domain name (.com) and linux web hosting on 12th of July 2012. After purchasing, I installed WordPress and used a free template with no fancy designs or images, but just a simple and clean template. I wrote about 13 blog posts in the first month. Then after i applied for Google AdSense.

My AdSense application was denied due to Copyright Issues. I didn’t give up because i was very sure that i didn’t copy paste any thread. All the content in my 13 posts was Original.

[sws_toggle1 title=”Application Denied Mail – Click To View”]


As mentioned in our welcome email, we conduct a second review of your
AdSense application once AdSense code is placed on your site(s). As a
result of this review, we have disapproved your account for the following


– Unacceptable site content
– Copyrighted Material
Unacceptable site content: In order to participate in Google AdSense,
publishers’ websites and application information must satisfy the
following guidelines:

*Your website must be your own top-level domain ( and not
*Your domain must have been registered and active for at least 6 months
before you apply for AdSense.
*You must provide accurate personal information with your application that
matches the information on your domain registration.
*Your website must contain substantial, original content.
*Your site must comply with Google AdSense program policies:

Copyrighted Material: We’ve found that your website contains copyrighted
material. As stated in our program policies
AdSense publishers are not permitted to place Google ads on sites involved
in the unauthorized distribution of copyrighted materials.

Unauthorized copyrighted materials include music, movies, images, or any
other copyrighted material that the publisher does not own or license from
the copyright owner.


So i took my problem to Google AdSense Product Forums and posted a thread there. A forum member named Luzie helped me to solve the problem.

He pointed out that i had copyright images on my blog. I removed the images and applied for AdSense once again. And this time i got approved.

The Easiest Way To Get Google AdSense Account Approved

  1. Get a Top Level Domain (TLD) like dot com, dot net, etc.
  2. Choose a Topic for your blog and focus on only one topic instead of many.
  3. Write about 10-20 Blog posts.
  4. Do not copy paste any text from any source.
  5. Do not use any image from the internet inside your blog post.
  6. Do not use fancy thumbnails for blog posts, they might be copyrighted.
  7. Write blog Consistently.
  8. Share your posts on Facebook, Google+, everywhere.
  9. Get your friends to visit your blog.
  10. Don’t get paid traffic for your website.
  11. Do the above steps for 1 Month and put your hardwork into it.
  12. After a month, Apply for Google Adsense.

If you follow the steps given above, I am sure your site will get approved for Google AdSense. Its really easy, provided – you follow the rules.

If you get approved then it will be your responsibility to keep Google Ads free from Invalid Click Activity. But do you know how to detect invalid click activity?

How To Detect Invalid Click Activity in Google Adsense

If you are an AdSense User, then it is important that you must  know how to Detect Invalid Click Activity in Google AdSense. Invalid Click Activity can get you banned from AdSense. You must be aware of that for sure. But do you know how to detect Invalid Click Activity?

Most of the publishers get banned because they don’t track their AdSense reports for any suspicious activity. You must track your AdSense reports on a regular basis, because once you get banned it might be too late to do anything about it.

In this post i will share few points which can help you to Detect Invalid Click Activity in Google Adsense. But before that lets define few terms which we will use.

[sws_toggle1 title=”Definitions – Click to View “]

Pageviews: One pageview is counted when a user views a page displaying Google ad.

Clicks: This is the number of times user has clicked on your advertisements.

CTR: Its called as Click Through Rate. It is in percentage. Its calculated as (Clicks/Pageviews) x 100.

CPC: Its called as Cost Per Click. Its the cost you get per click.

Estimated Earnings: This is roughly Clicks x CPC. It can change, go up or down because the earnings are still in verification process. [/sws_toggle1]

I will now use the definitions given above to share some tips which can help you to Detect Invalid Click Activity in Google Adsense.

Tips to Detect Invalid Click Activity

1) The CTR between 1% to 11% is usually considered normal. If CTR goes above 20% then you should consider doing something about it. If you get 25 clicks in 100 pageviews then you have about 25% CTR which is something to worry about.

2) If you get too many clicks but 0.00 CPC then those are invalid clicks. For example, if you get about 50 clicks with 0.00 CPC, then those were invalid clicks and were discarded by Google.

3) If you get Estimated Earnings equal to $0.60 and in the next minute or next hour it turns to $0.00 then this can be due to invalid click activity. In this type of problem, your earnings rise and suddenly disappear or become half when you refresh the page. This is because Google first considers the Clicks and the CPC for the same but after verification discards the invalid clicks.

4) If you get too many clicks from particular country but less pageviews then that can be a problem. Because the CTR would go high for that particular country. Or Too many Clicks but 0.00 CPC as shown in the image below.

detect invalid click activity country

That’s all for now. If you want to add any tip then feel free to comment below. Thanks. And Subscribe to blog feed to receive updates about new posts !

How To Track Invalid Adsense Clicks Using StatCounter

If you are getting Invalid AdSense Clicks then this post can help you. In this post i am going to talk about how to track Invalid AdSense Clicks using StatCounter.

Invalid Click Activity is a serious issue in AdSense and it can get you banned from AdSense permanently. Google doesn’t provide you with any tool to detect Invalid Clicks or Click Bombing. So you’re on your own in this mission of protecting your AdSense account from Invalid Click Activity.

Most people just end up losing their AdSense account because of Invalid Click Activity. But if you’re smart enough then you can track the location and IP address from where you are getting these Invalid Clicks.

You can track all clicks and exit links on your website using StatCounter. To use StatCounter, first register and create your account on it. Once you register, you’ll need to create a new project for your website which you want to track !

statcounter registration

Click on Add new Project. Then fill in the information – Project URL, Project Title, Country, Timezone, etc. You can select a counter or just select Invisible Tracking. You can also opt to receive monthly or weekly reports.

Once you click Add Project after filling up the appropriate data, StatCounter will detect the platform of your website and return you a code along with instructions on how to install the code on your website.

Tracking Exit Links

Once you have setup StatCounter for your website, you can start viewing reports within minutes. Now coming back to the Tracking Invalid Clicks part.


Click on Stats, Click on Exit Link Activity and you can find all the Links which you have visitors clicked to Exit from your webpage. You can find date, time, exit link name and also the page on which the exit link was clicked.

The exit link maybe a advertisement or a link to other website. So this way you can find how many clicks are there on advertisements and at what time the click was made.

But this information is not of much help, but you can find a Magnifying glass icon on every row of this table. If you click on magnifying glass you can find more information about the visitor who clicked on the link.

Track Invalid Adsense Clicks Using StatCounter

You can find the IP address of the visitor, his location, host name, browser, OS, resolution, ISP, visiting length, and the pages he viewed including the exit link.

In this way you can track the Valid as well as Invalid Adsense Clicks Using StatCounter. If you think you are being click bombed, you can temporarily disable advertisements on your website or remove your website from authorized websites list in Google AdSense.

But Remember that very first step is to detect any suspicious activity on your account, like a sudden increase in CTR (Click Through Rate) or high number of clicks but Zero CPC. Once you detect any suspicious activity, go ahead and track the location and ip address of the invalid click activity.

This is very useful because if at all you get banned from AdSense, you can have logs which you can use to appeal for your account being reinstated.

I hope this helps. I’ll be writing more about AdSense like Getting Approved and stuff like that. So make sure you subscribe to blog feed. And thanks for reading !

How To Add Print Button In WordPress Posts

Adding a Print Button in WordPress posts might be a good idea or a bad idea depending on what type of website you are running.

If you want your visitors to read your content only by visiting your website then adding a print button might be a bad idea. But if you blog about tutorials or how-to guides then providing a print button for your visitors might be a very good idea.

Visitors to a tutorial site or how-to site would love to print a post and follow it instead of carrying their computer, phone or tablet everywhere with them. So adding a Print Button in WordPress posts can be a good practice.

I will provide the Print Button Code in this post. All you have to do is insert this code inside the Single.php (Single Post) file of your current WordPress theme.

There are two parts in this post:

  1. First is a simple ‘Print This ArticleLink.
  2. And second part is Print Button.

So lets see how to add a “print this article” Link and Print Button in WordPress posts –

[sws_toggle1 title=”Print This Article Code – Click Here  “] <a href=”javascript:window.print()”>Print this Article</a> [/sws_toggle1]

I have tested this code on Twenty Eleven theme in WordPress. And it should work in your theme as well. Refer to the image below and follow these steps –

print this article link in wordpress post

  • 1) Open Administrators Dashboard > Appearance > Editor > Single.php
  • Add the given Print Code wherever you want it to appear.
  • I have added it just above the comments_template.
  • 2) Update File.
  • 3) Visit any post on your Blog, You can see ‘Print this Article’ Link at the end of the post.
  • The link appears after the content and before the comments.

But this just adds a Link instead of a Button. To add a button we will modify the code and add a image somewhere between there.

[sws_toggle1 title=”Print Button Code – Click Here”]

<a href=”javascript:window.print()”>

<img src=”×32/print.png” />



In Print Button Code, i have added a Print Icon Image. You can replace that image with any image icon you want. Just Google the image you want to use and replace the image link with your desired image link. Or else you can use the code as it is !

Follow the same steps to add the new code which will help you to add a Print Button to your wordpress theme. After adding the print button, it would look like this:

print button in wordpress post


Adjusting Position of Print Button in WordPress Post

The Print Button might or might not appear in correct position because it depends on your theme. So if you don’t like the current position of the Print Button in WordPress posts then you can go ahead and add inline style to it.

The print button appears to the extreme left side in Twenty Eleven theme. So i will add margin-left style to it and push it rightwards. I will add about 150px left margin, so it will be moved to right side by 150 pixels. Check the code given below.

[sws_toggle1 title=”Print Button with Positioning – Click Here”]

<span style=”margin-left:150px;”>

<a href=”javascript:window.print()”>

<img src=”×32/print.png” />




If you replace the Print Button code with the new Print Button with Positioning Code then you will get the following result –

position of print button in wordpress posts

And thus you can adjust the position of Print Button in WordPress posts by changing the value of margin-left attribute. If you have any questions feel free to comment below. Thanks for reading. And subscribe to blog feed if you like this post !