[Support request] Generic adsense code disappears from head

Home Forums Support [Support request] Generic adsense code disappears from head

Home Forums Support Generic adsense code disappears from head

  • This topic has 3 replies, 2 voices, and was last updated 1 year ago by David.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1489681
    Javier

    I use a plugin to insert the adsense ads but when I insert in the head the adsense code disappears after a short time. It only happens to me in generatepress, in other themes I have no problem.
    How can I create a general hook to insert the generic adsense code and not delete it automatically? Is there a way that the adsense code does not disappear from the template?

    #1489874
    David
    Staff
    Customer Support

    Hi there,

    there isn’t anything in GP that would affect the behaviour of that plugin. I would assume the plugin is adding code to core WP hooks which again GP has no awareness of or control over.

    If you know where the code needs to be added you can use a Hook Element:

    https://docs.generatepress.com/article/hooks-element-overview/

    There are 3 main hooks for adding scripts to WP:

    wp_head – inside the <head></head>
    wp_body_open – immediately after the opening <body> tag
    wp_footer – in the footer

    For ad placement codes there is a number of Theme hooks which you can see in the visual guide:

    https://docs.generatepress.com/article/hooks-visual-guide/

    #1489891
    Javier

    Thanks David,

    I have created a hook in wp_head that affects the whole site, this is how the main adsense script is executed, for now it works correctly,

    Javi

    #1489918
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.