One of the problems I often see when reviewing sites and helping to set up ads is a headline above the ads saying something like “partners” or “helpful links.” If this ad comes from AdSense, then you already violated their placement policies. So, let me show how to fix it.

Update: Since Advanced Ads 1.8 you can add a label to all of your ads or only to specific placements. Find the details in the manual.

AdSense is very clear about headlines and labels:

It’s important that visitors to your site are not misled in any way and are able to easily distinguish content from Google ads. This policy prohibits placing ads under misleading headings such as “resources” or “helpful links”. Publishers may only label ads with either “Advertisements” or “Sponsored Links”. No other variations are permitted.

I often see this violation in sidebars, because widgets allow you to insert a headline by default. You can use one of the allowed headings now or just leave it blank. AdSense doesn’t require you to add a headline if your ads can be distinguished from other content.

 

To enable a headline for ads in other positions you can use the following code in your theme’s functions.php. It will display the “Advertisement” heading above any AdSense ad.

This solution relies on the Advanced Ads plugin of course.

// add "ad" headline before ads
add_action( 'advanced-ads-output-final', 'my_advanced_ads_headline', 10, 2 );
function my_advanced_ads_headline( $output, $ad ){
	// check if this is an AdSense ad
	if( $ad->type !== 'adsense' ){
	    return $output;
	}

	$headline = 'Advertisement';
	$output = '<fieldset><legend>' . $headline . '</legend>' . $output . '</fieldset>';
	return $output;
}

You can remove the check for the AdSense ad to display the headline for other ad types as well. Just remove line 5 to 7.

Use the advanced-ads-output-inside-wrapper filter instead of advanced-ads-output-final if you want to display the label within the ad wrapper.

To change the headline, just modify the string in line 9.

Copy this code to your functions.php and it should work automatically.

You can also style the headline using CSS. Else, the default style of the fieldset and legend tags of your theme will be applied.