Grant Turck

Add Script After Opening Body Tag

6 posts in this topic

What file do I need to add code to in my pl-framework-pagelines child theme to insert script after opening body tag on every page?

Can you someone provide me with the code also?

Share this post


Link to post
Share on other sites

Hey @Grant Turck ... easiest way to do this is with a plugin, or Google Tag Manager (there are WP plugins for it)

 

if you want to add with a hook, it goes something like this in your function.php in a child theme: 

add_action('wp_footer', 'my_script');

function my_script(){
?>
// script code here
<?php 

}

 


Share this post


Link to post
Share on other sites

Where can I find <body <?php body_class(); ?>> within Pagelines? 

Share this post


Link to post
Share on other sites

why do you need that? you should be using hooks for everything...

It is inside a function call...


Share this post


Link to post
Share on other sites

Because it's how to insert the google tag manager script after the body tag. The second piece of the tag manager script must be placed after the opening body tag (not in the footer). If the script is not placed immediately before the opening body tag then tag manager won't function properly. 

See: http://www.internoetics.com/2014/01/02/add-a-hook-in-wordpress-after-the-opening-body-tag/

Share this post


Link to post
Share on other sites

try attaching to the pagelines_before_page hook :P


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • DanatTLFN
      By DanatTLFN
      Hi Pagelines Team,
      I am interested in setting up a bbPress forum on my website.
      Unfortunately, I have never set up a child theme for my site and have been just using the drag and drop system to put together my site on the main theme. If I am to install the child theme, and activate it, what do I stand to lose in terms of design and current configuration settings on the backend?
      Thank you for taking this time to read this.
      Kind regards,
      Dan
    • flourishdesignstudio
      By flourishdesignstudio+
      I installed the Pagelines.com child theme from the extend section. When I activate it and try to go to the site, it looks terrible! I realized that all of my widgets have moved to different sidebars. In addition to that issue is that the Page Editor is a blank area. Custome CSS, Templates, Etc shows up just fine.
      Everything has been updated and is current.
      Has this happened to anyone else? How do I correct it?
    • Audun MB
      By Audun MB+
      How do I get the LESS in a child theme to compile?
    • Tim Holmes
      By Tim Holmes+
      I created a 3 column layout with a main center column flanked by a left and right sidebar. I've been working on this website for the last couple weeks, but recently, I noticed the entire right sidebar containing a PLNextBox is gone. The column, which is usually indicated with a blue dashed line is also not visible.
      I rebuilt the 3 column layout, but after clicking around through the site, the right sidebar disappears again and again. The left sidebar contains a PLNextBox as well, but that column remains on the page. 
      Here is a sample page on the staging site. Debug has been enabled.
      http://mcrhlx.staging.wpengine.com/events/
      DMS Version: 2.2.1.1
      DMS Plugin Pro Version: 1.8.5
      WordPress Version: 4.4.1
      Any ideas of what could be happening? I am also repeatedly getting errors from my web host. See attached.
       

    • Le Chef Est Une Femme
      By Le Chef Est Une Femme+
      Hey everyone
      I am very sorry if this question has a "deja vu"  taste but I have been looking for more than 2 hours a way to add a phone number in the top right corner of my header website.
      Before asking that, I have read many of the questions related to that subject, from hooks and action map to function.php and hooker plugin but I am very lost. Plus many links kindly given by some of you are now 404 pages
      Is there anyone willing to help me find the easiest way to add this number please ? 
      In advance, thank you 
      www.upgrad.paris