Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress How to Build a WordPress Theme Preparing to Code WordPress Templates Linking CSS

Carla Thomas
seal-mask
.a{fill-rule:evenodd;}techdegree
Carla Thomas
Front End Web Development Techdegree Student 16,039 Points

Fatal error: Call to undefined funtion...

I keep getting the following error when trying to view the CSS files from the view-source page:

Fatal error: Call to undefined function get_header() in C:\xampp\htdocs\carlathomas.com\wp-content\themes\wpportfolio\index.php on line 1

My index.php file has the following three lines:

<<?php get_header(); ?>

<p>This is the index</p>

<?php get_footer(); ?>

What am I doing wrong? Thanks in advance.

3 Answers

Daniel Mironis
Daniel Mironis
14,023 Points

The problem can be in theme that you are using, either free or paid themes can have these issues.

Try using this:

if (function_exists('get_header')) {
     get_header();
} else {
     exit;
}
Carla Thomas
seal-mask
.a{fill-rule:evenodd;}techdegree
Carla Thomas
Front End Web Development Techdegree Student 16,039 Points

Thank you for the input. I will definitely copy/paste the above code for future troubleshooting....I did find the problem: I am currently building a theme on the WP Development track and found that I placed a comma (,) where a period (.) should have been.

missgeekbunny
missgeekbunny
37,033 Points

It would need to be something within your header file or in something that your functions.php file adds to the header. Either that or your local installation has broken somewhere. I know I stopped using MAMP after a while because my build kept breaking. I'd either try it on live server and see if you are still getting these errors or look over your files and make sure nothing is wrong. If possible I find it is always helpful to have a subdomain that's something like dev.mydomainname.com so I can test issues I'm having and making sure it isn't my local host (just cause I have had enough problems in the past for various reasons).

Carla Thomas
seal-mask
.a{fill-rule:evenodd;}techdegree
Carla Thomas
Front End Web Development Techdegree Student 16,039 Points

Thanks Bunnie. Yes, it was something in the coding on the functions.php file....and I will definitely use your idea of having a subdomain for testing. Thanks again.