0

Am new to WordPress theme. I tried writing this little code and got this

Warning: Use of undefined constant all - assumed 'all' (this will throw an Error in a future version of PHP) in C:\Users........ on line 6

Line 6 referring to:

wp_enqueue_style('style', get_stylesheet_uri(), NULL, microtime(), all);

This is the functions.php code:

<?php

// adding the CSS and JS files

function gt_setup(){
    wp_enqueue_style('style', get_stylesheet_uri(), NULL, microtime(), all);
    wp_enqueue_script('main', get_theme_file_uri('/js/main.js'), NULL, microtime(), true);
}

add_action('wp_enqueue_scripts', 'gt_setup');

And this is the style.css code:

body{
    background:red;
}

header.php code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GTCoding</title>

    <?php wp_head(); ?>

</head>
<body>

    <header>
        <h1>Header Here</h1>
    </header>

footer.php code:

<footer>
    <p>Footer goes here</p>
</footer>

    <?php wp_footer(); ?>
    

</body>
</html>

JS code:

alert("hi from main.js");
  • 1
    In your wp_enqueue_style() call, you need to put that "all" in quotes: 'all'. But that's a generic PHP issue, not WordPress-specific. – Sally CJ Jul 25 at 14:26
  • Thank you so much. From the tutorial it wasn't so. U just saved me some depressive moments. – Emmanuel Ifeanyichukwu Jul 25 at 14:36
  • 1
    Then it's probably a typo in that tutorial - if you can, notify the author so that they can fix it. – Sally CJ Jul 25 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.