Okay
  Print

How to add Google Adsense code in theme ads management or sidebar widgets

WordPress does not allow you to use JavaScript in unsafe places like widgets or theme content areas.

If you want to add Adsense (or other js code banners) in widgets use this plugins:

https://wordpress.org/plugins/enhanced-text-widget/

https://wordpress.org/plugins/google-publisher/

If you want to add Adsense (or other javascript code banners) in theme ads management you need to disable WordPress security functions in theme:

  1. Open file /inc/theme-functions.php from theme folder in plain text code editor (for example Notepad++, Sublime Text).
  2. Search for string _banner_show, you will find theme function related to ads display (on image you see carrie_banner_show, it can have another name depending on theme that you use). You need to remove wp_kses_post in this function from code like described on screenshot below:

  3. Make this changes and upload file to FTP (or edit it directly on FTP). Now you should be able to use JavaScript in theme banner ads management.
  4. If you want to add shortcodes support to ads management areas you can change wp_kses_post to do_shortcode instead of removing this.