Streaming live at 10am (PST)

Adding WebFlow js to WordPress


#1

I used the following script to enqueue the webflow.js file per the WordPress codex:

add_action( 'wp_enqueue_scripts', 'my_custom_script_load' );
function my_custom_script_load(){
  wp_enqueue_script( 'my-custom-script', get_stylesheet_directory_uri() . '/custom-scripts.js', array( 'jquery' ) );
}

The javascript is not working. It’s loading the file but I get these errors in the console:

custom-scripts.js?ver=4.9.8:7 Uncaught TypeError: Cannot read property 'tram' of undefined
    at Object.<anonymous> (custom-scripts.js?ver=4.9.8:7)
    at n (custom-scripts.js?ver=4.9.8:7)
    at Object.<anonymous> (custom-scripts.js?ver=4.9.8:7)
    at n (custom-scripts.js?ver=4.9.8:7)
    at Object.<anonymous> (custom-scripts.js?ver=4.9.8:7)
    at n (custom-scripts.js?ver=4.9.8:7)
    at Object.<anonymous> (custom-scripts.js?ver=4.9.8:7)
    at n (custom-scripts.js?ver=4.9.8:7)
    at custom-scripts.js?ver=4.9.8:7
    at custom-scripts.js?ver=4.9.8:clock7:

Is there a trick to getting Webflow js to work in WP?


#2

I added var $ = jQuery; to the beginning and those console errors went away.

but none of my javascript is working. So, I guess my question remains, is there some trick to getting webflow JS to work in a WP site?


#3

so helpful…

anyways I figured it out. There’s a weird bit in the webflow html element that needs to be added to the html element of your wordpress site.

looks something like this:

data-wf-domain="americleaniowa.com" data-wf-page="5b1e87cb1a995e0caaff7ea7" data-wf-site="5b1e87cb1a995e5f91ff7ea6"

If you don’t include that part (don’t copy and paste MINE you need to grab whatever is in YOUR Webflow html) in your WordPress html tag none of your WebFlow javascript will work.

You’ll of course want to create a child theme and edit your header.php file as I don’t know of another way to add attributes to your html tag.


#4

Hey James.

Having the same problem. Not a developer.
Where exactly did you add the “data-wf-domain…etc” to get it in the html element?

thanks.
Steve


#5

in the header.php file. You’ll want to create a child theme (I use the Orbisius child theme creator)