Where do I paste the lightbox form code in my WordPress theme?

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered
Just created our first lightbox form but am unsure as to where to paste the code in my Wordpress theme. Can you please point me to documentation or advise here?

Thanks!

Note: This conversation was created from a reply on: Sneak peek: New signup forms.
Photo of Silver Linings

Silver Linings

  • 10 Posts
  • 3 Reply Likes

Posted 4 years ago

  • 0
  • 1
Photo of Katie Lewis

Katie Lewis, Official Rep

  • 3414 Posts
  • 309 Reply Likes
Hello! You'll find all lightbox form steps here in our Resource Center.

The steps for WordPress are:
  1. To add the embed code to your WordPress website, log in to your WordPress Admin, look for the Appearance option and then select Editor.
  2. Open your theme's header.php file. In the editing window, scroll down until you see the </body> tag. Paste the embed code just before that tag. Click Update and you're done.
Photo of Silver Linings

Silver Linings

  • 10 Posts
  • 3 Reply Likes
Perfect, thanks so much. I'll give it a try now!
Photo of Silver Linings

Silver Linings

  • 10 Posts
  • 3 Reply Likes
Katie, I'm in my themes header.php file, and I'm searing for the tag </body> and don't see it. I even tried using the Find function and it's not being found.
Photo of Katie Lewis

Katie Lewis, Official Rep

  • 3414 Posts
  • 309 Reply Likes
Are you seeing the <body> tag -- just the opening tag? I'm wondering if the closing tag, </body>, is split into other files. I'm checking in with a product owner to see if I can clarify the steps in the Resource Center. In the meantime, you can paste the embed code below the opening tag.

Let me know if that doesn't do the trick!
Photo of Katie Lewis

Katie Lewis, Official Rep

  • 3414 Posts
  • 309 Reply Likes
Hi again! I connected with our product owner and just posted the new steps on the Resource Center page. Hope this helps!
Photo of Silver Linings

Silver Linings

  • 10 Posts
  • 3 Reply Likes
Hi Katie,

I followed the steps and it disabled my site. I was able to bring it back up because I've encountered code that has disabled my site in the past.

So here's what I did. Appearance > Editor > functions.php

At the bottom of my functions.php window there is a section that says:


/* Custom code goes below this line. */

/* Custom code goes above this line. */


I inserted the code as instructed on the Resource Center Page, which is:

<?php add_action( 'wp_footer', 'add_lightbox_code_to_footer' );
function add_lightbox_code_to_footer() { ?>
        Insert lightbox embed code here <?php } ?>


Then I inserted my lightbox code where instructed. So my completed code looked like this:


<?php add_action( 'wp_footer', 'add_lightbox_code_to_footer' );
function add_lightbox_code_to_footer() { ?>
        <script id="e2ma-embed">window.e2ma=window.e2ma||{};e2ma.accountId='1359983';</script>
        <script src="//embed.e2ma.net/e2ma.js" async="async"></script> <?php } ?>

And that is what disabled my site. Any thoughts? Do I need to ask the theme creators for guidance?

Thank you in advance!
(Edited)
Photo of Shopbuses.com

Shopbuses.com

  • 6 Posts
  • 0 Reply Likes
Silver Linings / Katie,

We had the same happen to our WP site.  Followed the instructions, but each time it disabled the site.  Any help would be great.

Thanks.
Photo of Katie Lewis

Katie Lewis, Official Rep

  • 3414 Posts
  • 309 Reply Likes
Hey there! We'd need to see the error message to really know what's happening, yet one thing to check is that there aren't any empty lines before the text you're pasting into the functions.php file. We've seen errors if there are empty line breaks.

You'll also want to make sure this exists in the footer.php file:
<?php wp_footer();?>
Photo of TN Democratic Party

TN Democratic Party

  • 1 Post
  • 0 Reply Likes
Hi Katie! I checked and that code was in my footer but when I added the code as instructed it disabled the site. Any update?
Photo of Paul Zimmerman-Clayton

Paul Zimmerman-Clayton, Official Rep

  • 400 Posts
  • 34 Reply Likes
Hey there, thanks for posting! We'll need a little more information before we can dig in. Can you tell us if you're getting a specific error message, or anything else about what's going on? Also, can you tell me more about what you mean by the site being disabled? 
Photo of Phillip Duncan

Phillip Duncan, Technical Services Consultant

  • 8 Posts
  • 4 Reply Likes
Official Response
The WordPress instructions have been updated with a method that should be a bit easier to implement. Editing the functions.php file in WordPress can sometimes cause issues if not done correctly. The easiest method is to edit the footer.php file as noted in the updated Resource Center post.