Jetpack: move Jetpack Ads further down in a post

Learn to customize the location of the in-post Jetpack Ads.

You’ve probably heard about Jetpack’s new Ads module: it allows you to insert ads in your posts, in your sidebar, and in the header of your WordPress site without having to worry about finding the right ad network, managing ad inventory, or worrying about the quality of the ads. It’s available to Jetpack Premium and Professional users.

To use the feature, all you have to do is to click on the toggle under the Jetpack menu in your dashboard. Jetpack takes care of the rest.

However, sometimes you may not be happy with the default placement of the in-post ads: they appear right below the post content. That’s great, but sometimes you may be using other plugins to insert elements in there, like sharing buttons, related posts, subscription forms, …

The code snippet below will allow you to move the ad box exactly where you want it to appear.

/**
 * Move Jetpack ads further down, below elements added by other plugins.
 *
 * @see https://wordpress.org/support/topic/how-to-reposition-ads/
 *
 * @param string $content Post content.
 */
function jeherve_ads_down( $content ) {
    /**
    * Disable default ads that get added below the content.
    *
    * @see https://developer.jetpack.com/hooks/wordads_inpost_disable/
    */
    add_filter( 'wordads_inpost_disable', '__return_true' );

    // Insert our custom ad.
    if ( class_exists( 'WordAds' ) ) {
        $custom_ads = new WordAds();
        return $content . $custom_ads->get_ad( 'belowpost' );
    }

    return $content;
}
/**
* I used priority 99 below.
* To move the ads higher, pick a higher priority.
*/
add_filter( 'the_content', 'jeherve_ads_down', 99 );

You can add that code to a functionality plugin like this one.

You could also use the same method to insert the ads anywhere on your site, by hooking into a different filter!

Not familiar with Jetpack Ads, né WordAds? Check this video!