How to control Jetpack Ad placements using Hooks

Looking to customize where ads are placed on your site?

WordPress.com and Jetpack Ads users have site-level access to toggle where ads are displayed below posts and at the top of each page. You can also obtain more granular control of your ad placements using widgets.

jetpack-ads-settings.png

On WordPress.com, you can find these controls on the WordAds settings page.
Using Jetpack Ads, you can find these controls on the Traffic tab in Jetpack’s settings screen.

In some cases, we’ve found users seeking additional control to specify whether ads display on specific pages or sections, so we’ve added a few hooks to Jetpack Ads to make that possible.

Currently, there are 4 filter hooks that will allow you to disable ads based on your choosing. These can also be nested within conditional statements – for example, if you wanted to disable body content ads in a certain category only.

Each of the code examples below can be safely pasted into your theme’s functions.php file, or you can use the examples as a guide to implement the hooks in your own custom plugin or other setup.


Disabling ads in the_content

Hook: wordads_content_disable
Filters enabling ads in `the_content` filter

Example:
add_filter( 'wordads_content_disable', '__return_true' );


Disabling ads in the_excerpt

Hook: wordads_excerpt_disable
Filters enabling ads in `the_excerpt` filter

Example:
add_filter( 'wordads_excerpt_disable', '__return_true' );


Disabling ads placed within posts

Hook: wordads_inpost_disable
Allow third-party tools to disable the display of in post ads.

Example:
add_filter( 'wordads_inpost_disable', '__return_true' );


Disabling header ads

Hook: wordads_header_disable
Allow third-party tools to disable the display of header ads.

Example:
add_filter( 'wordads_header_disable', '__return_true' );

This entry was posted in General. Bookmark the permalink.

One Response to How to control Jetpack Ad placements using Hooks

  1. Dennis says:

    Finally! What a great update! I waited for this and now I will enable WordAds again. Previously it was really bad because we always needed to contact you guys to make any changes. But now we can finally adjust it on our own.

    Thanks a lot for the improvement!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s