July 22, 2014

Textual description of firstImageUrl

How to Exclude Adsense Ads On WordPress Blog Post Using Slug

|
Here is another simple way to hide or exclude Adsense ad on a single WordPress blog post.

Besides using the post ID which I had written before, check out this method on how to exclude Adsense on a particular WordPress blog post.

It makes use of the WordPress slug.

A WordPress slug is a few words that describe a post or a page.

It is actually an URL friendly version of the post title.

It comes with a hyphen between each word of the title.

how to exclude Adsense ads on WordPress post using slug

How to Exclude Adsense Ads On WordPress Blog Post Using Slug


Now, let's find out how to do it:

STEP ONE

How To Look For WordPress Post Slug

1. Click on All Posts .

2. Select the particular blog post which you want to exclude Adsense ad.

3. Click on Quick Edit.

4. You should be able to see both the blog Title and Slug.

5. Just as an example, these are your three slugs from the the three blog posts that you do not want to have AdSense:

how-to-buy-iphone
tips-on-how-to-buy-stocks
useful-ideas-for-single-mothers


STEP TWO

1. Go to either the header.php and/or single post.php and look for your Adsense code.

2. Now add this code:

<?php
if (!is_single(array('
how-to-buy-iphone','tips-on-how-to-buy-stocks','useful-ideas-for-single-mothers')))
{
?>
YOUR ADSENSE CODE
<?php
}
?>
3. Click Update File button.

That's all.

Now you won't see any Adsense ad on these three blog posts.

*Here is a tutorial on how to block or exclude Adsense ads on single Blogger post.