Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

103
Vistas
Problems with wp_enqueue_script in WordPress

I am quite new to WordPress and coding in general, so bear with me. I have two separate files of code one with all the php and another with all the JavaScript. I need the php to read the JavaScript but when I look in the console of the browser it can't find the file. It appears to be looking in the wrong folder so it won't find it anyways.

Here is the code that I have used to try get it to read the JavaScript file

function wpdocs_theme_name_scripts() {
    wp_enqueue_script( 'pq-forms-script', get_template_directory_uri() . '/pqnewsletterform.js', array(), '1.0.0', true );
} 

I've tried to change get_template_directory_uri to get_stylesheet_directory_uri but that did nothing.

Any suggestions on how to fix this problem would be much appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this code.

You need to use plugin_dir_url( __FILE__ ) instead of get_stylesheet_directory_uri.

function enqueue_scripts() {
  wp_enqueue_script( 'form-js', plugin_dir_url( __FILE__ ) . 'pqnewsletterform.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts');
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda