0
votes

I don't know why I'm having this issue. I'm new to wordpress and I am following along with a 'freecodecamp' tutorial(youtube) on how to make a custom wordpress theme from scratch.

In the video, the instructor is enqueueing his style sheet using the functions.php file. Here is the exact code he is using...

Click here for code image

<?php
    function followandrew_register_style() {
        wp_enqueue_style('followandrew-bootstrap', get_template_directory_uri() . "/style.css", array(), '1.0', 'all');

    }
        add_action('wp_enqueue_scripts', 'followandrew_register_style' );
?>

Click here for error image

Visual Studios is prompting this error as soon as I write out the commands...

"Undefined function 'wp_enqueue_style', and undefined function 'add_action'.

I am including "wp_head()" inside my front-page.php to output the stylesheet.

Everything else is working fine. I am able to see my basic html setup when posting in inside the "front-page.php". My wordpress is connected correctly and I have access to the backend admin.

If I hardcode the path to the style sheet inside of front-page.php, it works fine.

So basically, any functions or commands I try to run inside the functions.php file are coming back undefined!

1
but have you tried to execute the code? Visual studios may be not aware of that function as it's hidden somewhere in the wordpress core. Your code looks ok reallyAndrei Filonov
The coding appears correct. Maybe VisualStudio is not detecting the WP environment. Test with print_r(defined('ABSPATH')); The result will be 1 when in the WP scope. If it is 0, the functions.php is not being loaded.Nadal
I tried print_r(defined('ABSPATH')); and it comes back with 1. I even did a simple echo "Does this output to the actual page?" ... and it does!AlbertEinstein
I'm just going to leave it alone for now, just kinda weird that I'm getting the error in the first place. Thanks for replying back guys!AlbertEinstein

1 Answers

0
votes

Nevermind, it looks like everything is working fine. I just had the wrong source path for the custom css link.

VS code is still displaying the undefined error but everything is working.

Best 5 hours Ive ever wasted :)