You can insert Adsense ads to your posts using the Adsense widget shortcode. The most basic version of adsense shortcode is;


By default, this shortcode displays ads using your publisher id and other shortcode settings you have specified on the Adsense Widget settings page.

Did you know that you can use shortcodes in widgets too? Not all themes allow that. But if you know a little about PHP and WordPress, you can read our guide on how to enable shortcodes in widgets.

You can find a more complete version of the shortcode below:

[[adsense userid="pub-xoxox" format="display" align="none" slot="xxx" sizes="sm-banner md-rectangle lg-leaderboard"]]

Let me explain each of the options you can specify on the shortcode in depth.

Shortcode Options

userid or pubid

This is your adsense publisher id. It starts with “pub-“. If you don’t specify this option it uses the publisher id specified on the Adsense Widget settings page.


This is the Adsense ad format in lowercase. It accepts the following values:

  • display: Display ads
  • in_feed: In-Feed ads
  • in_article: In-Article ads (use only inside posts)
  • matched_content: Matched content ads
  • link: Link ad units


You can align ad units to center, right or left using this option. It uses the CSS float property. It must be used carefully, as it may cause ad units to overflow containing elements.


If you want to measure the performance of your ad unit, it is best to specify a slot id for the shortcode. You can specify a common slot for all of your shortcodes using the Adsense Widget settings page.


You can specify responsive ad sizes using the sizes argument of the shortcode. It allows you to specify multiple size classes for one shortcode.

Please visit Adsense Widget Sizing Options to learn more about sizing your ads.