Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress From Bootstrap to WordPress Setup a Bootstrap Theme Create the Basic WordPress Theme Files

irmarie govind
irmarie govind
96 Points

getting fatal error on index.php

Hello. I am following your tutorial however I'm getting a fatal error when placing the <?php get_header(); ?> code into the index.php file. Any suggestions of how to fix this?

6 Answers

irmarie govind
irmarie govind
96 Points

Hello Zac.

I found the solution to my problem. The issue was that I was trying to preview the theme files in Dreamweaver instead of the index.php in the wordpress root folder. I am new to Wordpress as well so I was kind of confused. Anyway, thank you so much for your reply and for Dustin's help as well. Very much appreciated.

Hi irmarie!

Here's what you should have for header.php.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="../../assets/ico/favicon.ico">

    <title>Jumbotron Template for Bootstrap</title>

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <?php wp_head(); ?>

  </head>

  <body <?php body_class(); ?>>

    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Project name</a>
        </div>
        <div class="navbar-collapse collapse">
          <form class="navbar-form navbar-right" role="form">
            <div class="form-group">
              <input type="text" placeholder="Email" class="form-control">
            </div>
            <div class="form-group">
              <input type="password" placeholder="Password" class="form-control">
            </div>
            <button type="submit" class="btn btn-success">Sign in</button>
          </form>
        </div><!--/.navbar-collapse -->
      </div>
    </div>
irmarie govind
irmarie govind
96 Points

Hello Dustin and thank you so much for your reply.

I placed the code that you sent me and still does not display the index.php page correctly.

Let me explain what's going on....I followed Zac's tutorial and everything works fine until I place the <?php get_header(); ?> and <?php get_footer(); ?> code into the index.php page and try to preview it in my localhost. That's when I get the fatal error message.

Now, when viewing these files independently header.php and footer.php it renders the page correctly.

Any suggestions or another workaround?

Thank you so much for your help.

Is there a way you could post the contents of the two files, or better yet, zip the project and upload it to Dropbox?

irmarie govind
irmarie govind
96 Points

Hello Dustin.

I'm new to this forum so please bear with me. :-)

Here is the code that I have on the index file:

https://www.dropbox.com/s/x0779a6xzqpo0az/index-page.txt

This is the page that when trying to preview in the browser displays a fatal error.

Let me know if the file displays correctly as this is the first time I am using Dropbox.

Thanks a million for your assistance.

See if you can grab your error log and see what's going on there.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

If you remove one or both of the PHP lines of code, what happens? It could be that there is perhaps an error in the header or footer files that is being included and breaking something.

irmarie govind
irmarie govind
96 Points

Hello Zac and thank you so much for your reply.

When removing the php lines of code, the page displays correctly. I am following your tutorial in this link: http://blog.teamtreehouse.com/responsive-wordpress-bootstrap-theme-tutorial and I'm still having this issue.

I am working in a local server and everything works fine until I place the php code in the header and footer.

Please help! Thanks!