PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Shortcode & WP_Query does not load gravityforms.js

  1. We have a page in which we display posts using WP_Query, one of those posts has the following shortcode:

    [gravityform id="1" name="Something" title="false" description="false" ajax="true"]

    This worked until we added conditional logic, at which point display:none was added.
    Viewing the post on its own (in which the post was displayed using "the loop" instead of WP_Query), the form suddenly worked again.

    After comparing the differences, we saw gravityforms.js was not loading.
    Adding the following code to header.php solved the issue:

    wp_register_script("gforms_gravityforms", GFCommon::get_base_url() . "/js/gravityforms.js", null, GFCommon::$version);
    wp_enqueue_script( 'gforms_gravityforms' );

    My suggestion to fix this is:
    + Always register all the scripts using wp_register_script (right now it only registers the script when there is an actual form, which kind of defeats the purpose of register & enqueue script)
    + Document the need for wp_enqueue_script( 'gforms_gravityforms' ); in a special case like this. For example in the faq

    Posted 12 years ago on Wednesday July 11, 2012 | Permalink
  2. Moved to feature requests

    Posted 12 years ago on Wednesday July 11, 2012 | Permalink