Support » Plugin: Per page add to head » Can this add code to the header right after opening head tag?

  • Resolved capsid

    (@capsid)


    Hi, I want to use this plugin to run Google Content Experiments. The instructions say the experiment code needs to be injected directly after the opening head tag. In the changelog I saw that this plugin injects code at the end of the header. Is there any way to change that behavior, or do you think Google is suggesting something that isn’t actually required? Thanks for your help 🙂

    https://wordpress.org/plugins/per-page-add-to/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Erikvona

    (@erikvona)

    You can change the order of appearance by editing the plugin, as discussed earlier in this support forum post.

    In your case, you will have to use a low integer, like 1 or 0.

    So just edit the perpagehead.php, line 114:
    add_action('wp_head', 'perpageath_display', 1000);
    becomes
    add_action('wp_head', 'perpageath_display', 1);

    This will place the add to head content at the top of the wp_head queue. However, some themes add content to the head tag outside of the wp_head action. If this is the case with your theme, there is no way to get the content to show up first, besides editing your theme.

    Of course, any changes you make to the plugin will reset after a plugin update, so keep that in mind.

    If more people want to customize this setting, please reply to the support forum. I can easily make an option for this (but I want to keep the option count as low as possible for load times/keeping the plugin simple).

    Thanks @erikvona This was exactly what I was looking for. 0 did not work but 1 did. It moved the script much further to the top but not directly after the opening <head> so hopefully it will be high enough in the code for Google to find it. Fingers crossed.

    I want to give a try to adsense, I have a host adsense account for my youtube channels.
    I tried to upgrade and than aded their script code in my html head tag via a plugin. I done it about one week ago. I have not received any email from adsense about approval or disapproval.
    I am thinking that html code is not propetly inserted.
    I have searched google for edit my html but not found any accurate ans. In wordpress theme editor, there are only php files.
    So please help me how can i edit html? So that i can add that code right after the head tag?
    Thanx.

    Plugin Author Erikvona

    (@erikvona)

    Dear @waseemsajjad431
    This is a support form for a specific plugin, not a general place to ask questions. If you have issues using my plugin, or questions about it, please describe the problem.

    WordPress is a CMS, so you cannot edit the HTML directly, only the PHP that generates the HTML.

    Furthermore, if you expect me to put effort into answering questions, please put effort into asking them as well (proper English, proper description of the issue).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can this add code to the header right after opening head tag?’ is closed to new replies.