Title: .flexslider is not a function error
Last modified: June 5, 2017

---

# .flexslider is not a function error

 *  [James Maiden](https://wordpress.org/support/users/reallygreenjames/)
 * (@reallygreenjames)
 * [9 years ago](https://wordpress.org/support/topic/flexslider-is-not-a-function-error/)
 * Hi there,
    Having used the plugin for a long time, I now have a js error for 
   all of my sliders, such as…
 * This is the output:
 * `jQuery('#flexslider_hg_home').flexslider( {"slideshowSpeed":6000,"animationSpeed":
   4000,"animation":"fade","direction":"horizontal"} );`
 * This is the console error:
    TypeError: jQuery(…).flexslider is not a function
 * As a result, the sliders don’t display, though the html is there in the mark-
   up

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Pat K](https://wordpress.org/support/users/blackcapdesign/)
 * (@blackcapdesign)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/flexslider-is-not-a-function-error/#post-9263789)
 * Hi ReallyGreenJames,
    Do you by chance have WooCommerce installed? I have HG 
   Slider on a number of projects and it’s working fine with WP 4.8. I ran some 
   tests and as soon as I install the latest version of WooCommerce, HG Slider stops
   loading (same as you described above). I haven’t found a solution yet. If I find
   one, I’ll post it here. PK
 *  Thread Starter [James Maiden](https://wordpress.org/support/users/reallygreenjames/)
 * (@reallygreenjames)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/flexslider-is-not-a-function-error/#post-9265044)
 * Hi Pat,
    I do have WooCommerce installed. That’s interesting.
 * I found a workaround by simply adding my own call in the site’s header, just 
   before the closing `</head>`:
 *  `<script type=”text/javascript” charset=”utf-8″>
    jQuery(window).load(function(){
   jQuery(‘.flexslider’).flexslider(); }); </script> `
 *  [Pat K](https://wordpress.org/support/users/blackcapdesign/)
 * (@blackcapdesign)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/flexslider-is-not-a-function-error/#post-9265522)
 * Works! Thanks for sharing your workaround ReallyGreenJames!
 * PK
 *  [hanheg](https://wordpress.org/support/users/hanheg/)
 * (@hanheg)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/flexslider-is-not-a-function-error/#post-9394797)
 * Thanks guys. I had the same problem. Flexslider in combination with Woocommerce
   stopped working. But the workaround solved the issue for now.
 *  [mossyrock](https://wordpress.org/support/users/mossyrock/)
 * (@mossyrock)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/flexslider-is-not-a-function-error/#post-9696193)
 * I had the same issue when I upgraded WooCommerce.
 * Thanks for the work-around, Pat! Calling the flexslider function again after 
   the document loads did fix my slider, but it didn’t get rid of the console error
   from the original function call.
 * I found what I think is the root of the problem. I noticed that the flexslider
   shortcode PHP function embeds a javascript call to the jQuery.flexslider function
   directly in the HTML rather than calling it only after the document is ready.
   Since the WooCommerce updated the version of jQuery flexslider, it gets loaded
   later and it’s not yet defined when the shortcode HTML gets loaded.
 * I fixed up the PHP code by adding two lines to the show_flexslider_rotator function
   to ensure the flexslider function is only called after the document is ready.
   You can see which lines I added by looking at the two lines of code that begin
   with a + plus sign. (Don’t copy the plus sign into your PHP code).
 * Here is the patch:
 *     ```
       Index: wp-content/plugins/flexslider-hg/flexslider-hg.php
       IDEA additional info:
       Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
       <+>UTF-8
       ===================================================================
       --- wp-content/plugins/flexslider-hg/flexslider-hg.php	(revision 404db2e72def25bde08da3f45dc0922b19301fc0)
       +++ wp-content/plugins/flexslider-hg/flexslider-hg.php	(revision )
       @@ -271,6 +271,7 @@
   
        		// INIT THE ROTATOR
        		$rtn .= '<script>';
       +		$rtn .= " jQuery(document).ready( function() {";
        		$rtn .= " jQuery('#flexslider_hg_{$slug}').flexslider( ";
   
        		if(isset($rotators[ $slug ]['options']) AND $rotators[ $slug ]['options'] != "") 
       @@ -279,6 +280,7 @@
        		}
   
        		$rtn .= " ); ";
       +		$rtn .= "} );";
        		$rtn .= '</script>';		
        	}
        	wp_reset_postdata();
       ```
   
    -  This reply was modified 8 years, 6 months ago by [mossyrock](https://wordpress.org/support/users/mossyrock/).
 *  [Pat K](https://wordpress.org/support/users/blackcapdesign/)
 * (@blackcapdesign)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/flexslider-is-not-a-function-error/#post-9696830)
 * Hey Mossyrock, great detective work! Thanks for sharing your patch!
    PK

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘.flexslider is not a function error’ is closed to new replies.

 * ![](https://ps.w.org/flexslider-hg/assets/icon-256x256.png?rev=970026)
 * [Responsive WordPress Slider - HG Slider](https://wordpress.org/plugins/flexslider-hg/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/flexslider-hg/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/flexslider-hg/)
 * [Active Topics](https://wordpress.org/support/plugin/flexslider-hg/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/flexslider-hg/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/flexslider-hg/reviews/)

## Tags

 * [flexslider](https://wordpress.org/support/topic-tag/flexslider/)

 * 6 replies
 * 4 participants
 * Last reply from: [Pat K](https://wordpress.org/support/users/blackcapdesign/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/flexslider-is-not-a-function-error/#post-9696830)
 * Status: not resolved