Jetpack: move Jetpack Ads further down in a post

in WordPress

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.

<br />
/**<br />
 * Move Jetpack ads further down, below elements added by other plugins.<br />
 *<br />
 * @see<br />
 *<br />
 * @param string $content Post content.<br />
 */<br />
function jeherve_ads_down( $content ) {</p>
<p>	/**<br />
	 * Disable default ads that get added below the content.<br />
	 *<br />
	 * @see<br />
	 */<br />
	add_filter( 'wordads_inpost_disable' , '__return_true' );</p>
<p>	// Insert our custom ad.<br />
	if ( class_exists( 'WordAds' ) ) {<br />
		$custom_ads = new WordAds;<br />
		return $content . $custom_ads-&gt;get_ad( 'belowpost' );<br />
<p>	return $content;<br />
}<br />
/**<br />
 * I used priority 99 below.<br />
 * To move the ads higher, pick a higher priority.<br />
 */<br />
add_filter( 'the_content', 'jeherve_ads_down', 99 );<br />

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!