Remove Ads for Registered Users or Admin on WordPress Blog

by Hiroshi on November 23, 2008

in Hacks, WordPress

While applying modifications online at your WordPress blog sometimes you have to re-re-refresh the blog to view quick changes. Well! you are running a blog, so you have Adsense or other Ads code too. You do not want to get banned from adevrtising companies. Right?

While you are modifying the code, so you will be logged in. We can hide the code when admin user is still in session or when he is logged in, code will not be displayed.

We just have to use the is_user_logged_in() function, which returns true if an user is logged in.

Just paste the following code anywhere on your theme where you display ads.

if (!is_user_logged_in()) {
// Insert Adsense (or whatever) code here
}

Related Posts

Previous post:

Next post: