Following is a short tutorial how to get your Adsense code set up to work as a shortcode.
This is very effective if you want to place advertisements within a post or page.
So firstly log into your WordPress dashboard and browse over to Appearance > Editor.
Open up functions.php and scroll to the bottom.
Before the closing ?> paste the code below.
/**
* Google Adsense Shortcode Function
* @author Joakim - www.jocha.se
* @link https://jocha.se/blog/tech/adsense-shortcode-for-wordpress
*/
function adsense_function() {
return '
PLACE_ADSENSE_CODE_HERE
'; }
add_shortcode('my_ads', 'adsense_function');
Save the file, head over to your post or page of choice and simply write [my_ads] to place an ad.
It will end up looking like this:


