Wordpress error when adding scripts in footer and styles in header with enqueue

Asked

Viewed 31 times

0

Code

functions.php

add_action('wp_enqueue_scripts', 'enqueue_scripts');

//add_action('init', 'enqueue_scripts');
//tentei também com o init, chega a chamar as funções do functions.php e mostra algo se eu colocar o printr, mas nada dos scripts e estilos :c

 function enqueue_scripts() {
    wp_enqueue_style('css-lindo', get_template_directory_uri() . '/assets/css/meu-css-lindo.css');

    wp_enqueue_script( 'js-bonito', get_template_directory_uri() . '/assets/js/que-js-bonito.js', true);
    wp_enqueue_script( 'js-mara', get_template_directory_uri() . '/assets/js/js-mara.js', array ('jquery', 'que-js-bonito'), '1.0', true); 
}

Yes the files have been checked and are in the directories, when seeing the source code nothing in the header and footer. The function is being called, if I use the add in init and put a printr appears the string.

Thank you.

  • It seems you need to register the style or script, take a look at this wp_register_style('my_stylesheet', plugins_url('my-stylesheet.css', FILE));, should be used before wp_enqueue_script() for each one, I will not make an answer as I am not sure.

  • 1

    Your header file has the wp_head()? function and the footer has the function: wp_footer()?

  • after I added this wp_head and wp_footer the scripts appeared but the js are printing under the css instead of at the bottom of the page.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.