0

I'm trying to inject a style.css script into my front-page.php. None of the styles load. In the tutorials, when you inspect page source, all the CSS should be there, but it simply shows the wp_head() script without injecting anything. Any advice is greatly appreciated!

front-page.php

<head>
    <php? 
        wp_head(); 
    ?>
</head> 

functions.php

<?php

function load_scripts(){
    echo "Hello Functions!";    
    wp_enqueue_style('any-style-name',  get_stylesheet_directory_uri() . '/style.css');

}


add_action( 'wp_enqueue_scripts', 'load_scripts');  

folder structure

enter image description here

Other scripts I have tried using in load_scripts

wp_enqueue_style('any-style-name', get_stylesheet_uri());
wp_enqueue_style('anydescription', get_stylesheet_uri(), array(), "1.0", 'all'); 
wp_enqueue_style("anydescription", get_template_directory_uri() . "/style.css", array(), "1.0", "all");
1
  • 4
    Is your invoking wp_head() really precluded by <php? or was that a typo in the question?
    – butlerblog
    Dec 18, 2022 at 21:28

1 Answer 1

1

Your php code block is not properly formated.
You currently have this

<php? 
    wp_head();
?>

Notice the opening php tag <php?, a correct php tag is <?php.
A less than symbol < followed by a question mark ? followed by the word php.
So a proper php block would look like this

<?php
    // Your code here
?>

There are others you can check out in the official documentation, https://www.php.net/manual/en/language.basic-syntax.phptags.php

1
  • I've been reviewing my code a million times but didn't see an error so simple. Thanks so much! Is there some sort of extension yo use to catch errors like this in the code editor? Dec 20, 2022 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.