Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#46036 closed defect (bug) (invalid)

Using of wp_register_script , wp_enqueue_script and wp_enqueue_style to add scripts of a plugin (Gravity Forms) in a custom theme is not working

Reported by: justinahinon's profile justinahinon Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Script Loader Keywords:
Focuses: Cc:

Description

I've tried several times to add styles and script from Gravity Forms to the functions.php file of a custom theme I'm building.

Here's the piece of code I'm using

<?php
function add_gravity_forms_scripts() {     
    // The gravity forms folder is placed on the custom theme main folder
     
    wp_enqueue_style('gravity_forms_css', get_template_directory_uri() . '/gravityfomrs/css/formsmain.min.css' , '', false);
     
    wp_enqueue_script('gravity_forms_script', get_template_directory_uri() . '/gravityfomrs/js/forms.min.js' , '', false);
 }
 add_action( 'wp_enqueue_scripts', 'add_gravity_forms_scripts' );
?>

The gravity form is directly added to a page using the gravity forms function call:

<?php
gravity_form( $id_or_title, $display_title = true, $display_description = true, $display_inactive = false, $field_values = null, $ajax = false, $tabindex, $echo = true );
?>

I tried the same methods on a new custom theme and still having the same issue: the styles and scripts didn't loaded lke the wp_enqueue function is not working

I'm using the last WordPress version (5.0.3) on an online server.

Change History (1)

#1 @desrosj
5 years ago

  • Component changed from Plugins to Script Loader
  • Focuses template coding-standards removed
  • Keywords needs-testing removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Severity changed from minor to normal
  • Status changed from new to closed
  • Version 5.0.3 deleted

Hi @justinahinon, thanks for this ticket and welcome to Trac!

This Trac instance is for the development of the WordPress core software and not for general support. I recommend opening a ticket in the WordPress.org support forum if you are still unable to get this to work.

It does look like you have a typo in your file path, though (gravityfomrs). get_template_directory_uri() also returns the theme URL and not the plugin folder URL. If those paths do not exist in your theme, that could also be the issue.

Good luck!

Note: See TracTickets for help on using tickets.