简体   繁体   中英

I have a problem with the function.php in the wordpress

I have problem with the style and js function its not displayed. here is my function.php I already add wp_head in header.php and wp_footer and the stlye is not displayed.

 <?php function gt_setup(){ wp_enqueue_style('google-fonts','//fonts.googleapis.com/css2?family=Raleway:wght@100&family=Roboto:wght@100&display=swap'); wp_enqueue_style('fontawesome','//use.fontawesome.com/releases/v5.8.1/css/all.css'); wp_enqueue_style('style',get_stylesheet_uri(),NUll,microtime(),all); wp_enqueue_script("main",get_theme_file_uri('js/main.js'),true); } add_action('wp_enqueue_scripts','gt_setup'); ?>

as Bruno pointed, rename your file to functions.php and use this code: i had removed wrong syntax and add right syntax to call your script in footer

<?php
function gt_setup(){

    wp_enqueue_style('google-fonts','//fonts.googleapis.com/css2?family=Raleway:wght@100&family=Roboto:wght@100&display=swap');

    wp_enqueue_style('fontawesome','//use.fontawesome.com/releases/v5.8.1/css/all.css');
    wp_enqueue_style('style',get_stylesheet_uri(),NUll,microtime());
    wp_enqueue_script("main",get_theme_file_uri('js/main.js'),[],'',true);
}

add_action('wp_enqueue_scripts','gt_setup');
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM