All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

WordPress error: call to undefined function get_header()

  • # May 6, 2011 at 11:42 am

    Howdy folks, firstly I’d like to thank Chris and Jeff for writing such an amazing book! I’m very new to WordPress and the book was perfect for getting me started the right way :) That being said…

    I’ve taken a little bit from the book, a little bit from the ‘twentyten’ theme, and a little bit from a few other themes, all to try to make my first theme (which is very, very basic). Now, I’ve got my file structure just like the book says (security through obscurity), and while testing my theme I’m getting the following error:

    Fatal Error: Call to undefined function get_header() in …

    I’m in serious need of help here folks, I’m not new to programming, but I’m a big WP noob for now.

    Secondly, and this is something that is truly confusing me…I’m unable to get any content (posts, pages, etc) in my new theme even though about 90% of the code is the exact same as the code in ‘twentyten’. Any idea why my loops might not be working?

    # May 6, 2011 at 11:45 am

    Many times this error comes up due to a plugin that has been installed. Deactivate all of your plugins to see if it is fixed. If the error goes away, re-activate them one by one until you find the culprit.

    The 2010 Theme has its Loops set up quite differently to how I do it, so I can’t quite comment on it. If you post the code that you have for page.php and single.php I’m sure I can get a better idea.

    # May 6, 2011 at 11:48 am

    Thank you so much for you quick and kind response!


    < ?php

    < ?php get_template_part('loop', 'page'); ?>

    < ?php


    < ?php

    < ?php get_template_part('loop', 'page'); ?>

    < ?php

    I’m on a local install, so I’d be surprised if it was a plugin, but I’ll check while you review this code :P

    # May 6, 2011 at 11:50 am

    Wow, that really butchered my code, those br tags shouldn’t be there!

    (Edit: Fixed by TheDoc)

    # May 6, 2011 at 11:54 am

    Btw, my local install has 0 ZERO zip NADDA plugins installed

    # May 6, 2011 at 12:24 pm

    It could be a problem with the file type — I’ve experienced this same problem working in Coda if I just click the ‘new file’ icon instead of creating a new html-php file through ‘File -> New’. I don’t have enough knowledge to explain *why* that’s the case, though. Hopefully someone else can?

    # May 6, 2011 at 1:02 pm

    On either page.php or single.php, replace your call to the Loop with this:

    < ?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

    < ?php the_title(); ?>

    < ?php the_content(); ?>

    < ?php endwhile; ?>

    That will make sure at least that things are working as they should.

    # May 6, 2011 at 1:25 pm

    Thank you for your help guys, the problem has been solved :) Doc, you are right in your method, but I backtracked and discovered that my loop.php had a large number of syntax errors. So once I fixed those, the problem cleared right up!

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed