Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda