Tagged: Essence Pro
November 27, 2018 at 6:40 am #224622
I have just moved my site to the Essence Pro theme and I am using LatestPosts/widgets option to create the front page with Essence widgets. The issue I have is that previously the front page was a static page and I was able to very simply add a script to just the front page of the site using header scripts for that particular page.
I am not certain how to do that when the front page is not a page/post, but created using widgets as I have done in Essence pro.
How do I add a script, not globally in the Genesis settings, but specifically just to show on the front page of the website.
The website is pureread.comNovember 27, 2018 at 6:52 am #224623November 27, 2018 at 9:16 am #224627
hi Victor, thanks for that. Not being a techie the idea is a bit foreign to me. is there a simple way to accomplish this, or dummies instructions I can follow somewhere?
I dont suppose anyone knows a plugin that might do the lifting for me?November 27, 2018 at 11:46 am #224629
Even with a plugin, you'd have to write code.
In the front-page.php file for Essence Pro, the front page scripts are loaded at line 29. Line 29 calls a function found at line 78. This is where you add your script. Assuming the script is jQuery, you would do the following:
- Save the script to a file. Name it whatever you want but make sure it has a .js extension. Make sure the file is in the theme's js directory
- If the script is wrapped in the script tags, remove the script tags.
- Add the following to the function at line 78:
wp_enqueue_script( 'my-front-script', get_stylesheet_directory_uri() . '/js/my-front-script.js', array( 'jquery' ), CHILD_THEME_VERSION, true );
November 27, 2018 at 11:54 am #224630
thank you so much!November 27, 2018 at 11:57 am #224632
So if my script is
what would I paste into a text doc and save (you mention removing script tags)
sorry for being so slow.....November 27, 2018 at 12:14 pm #224634
That script won't work with wp_enqueue_script. You'll have to go about this in a completely different way. This snippet will do it for you if you add it to the bottom of functions.php:
November 27, 2018 at 12:32 pm #224635
Victor, I hope you know how amazing you are!
- The topic ‘Adding a script to homepage in Essence Pro’ is closed to new replies.