How to Embed Google AdSense Code inside a WordPress Post without Any Plugin

WordPress does not let you embed PHP code inside the posts but uses a feature to create Shortcode functions which are executed whenever they are encountered within a post. This is pretty handy feature since this gives you capability to add some PHP code in your WordPress files and then call it from your posts. The PHP code can be added to Theme’s functions.php file. We can use this to load ads from within the posts. Go to WordPress administration -> Appearance -> Editor -> By default style.css is opened for editing. Open functions.php by clicking on the file name on right hand side listing. Now copy the following code at the end of the file and change the return string to your Adsense code. Shortcode is defined by calling add_shortcode function and passing two parameters to it. The first one is a given name which will be used in the posts to call this[…]