I am trying to: add a <script> tag to a specific part of my layout (for google adsense). I've added the code that was supplied by google.
I save the VE cell and reload the front-end web page but the content doesn't show up.
When I then open the visual editor cell again, the script tags have been removed. This doesn't seem to happen if I just add a script tag on a standard wordpress page editor.
Am I missing something?
Any help is always much appreciated.
Dear daniel,
This expected result, We sanitize HTML and do not allow Scripts in Layouts visual editor Cells.
I suggest you replace the visual editor cell with Content template cell,
https://toolset.com/documentation/user-guides/content-template-cell/
then you will be able to setup the custom JS codes in the javascript window of content template
Thanks for the help,
I get that I can put the actual JS code in the JS editor.
So what would be the advised way of adding the call to:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
I have to say I'm surprised at how hard it has been to copy and paste a snippet from google. I can't be the only toolset user using adsense =0]
You can create a custom shortcode for it, for example, add below codes into your theme/functions.php:
add_shortcode( 'ggad', 'ggad_func' );
function ggad_func() {
return '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>';
}
Then put the shortcode [ggad] into the content template or visual editor content. and test again.
OK, please let me know if you need more assistance for it, thanks