WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Call to undefined function get_header() (7 posts)

  1. empulse
    Member
    Posted 3 years ago #

    First and foremost, I'm in way over my head. I really don't know what I'm doing here (surprise, suprise, right?!) but through lots of research and trial and error I have the front page of my site up and running on my localhost.

    All runs and looks fine on the front page. Its a simple page that has links in the header, a swf animation and a call to get the most recent 2 posts. All of that works wonderfully, but as soon as I press one of my links (the link to "Press" in this instance) everything goes to hell. I get the following message: Fatal error: Call to undefined function get_header() in C:\W\WD\xampp\htdocs\wp-content\themes\MaybeMarquis\press.php on line 7

    From research I've done it appears that this sort of thing happens when you start moving files from one place to another and editing files in the root and not in the theme file... But I haven't done that. The files in root are 100% unedited and the only thing I've touched is stuff in the MaybeMarquis file. Any chance someone can give me a hand here? I'm a tad frustrated and would be grateful for the assistance!!

    Thanks in advance.

    header.php (Works with index.php :: Location: wp-content\themes\MaybeMarquis\)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <title>
    <?php wp_title('-',true,'right'); ?>
    <?php bloginfo('name'); ?>
    </title>
    <link rel="Shortcut Icon" href="<?php echo bloginfo('template_url'); ?>/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <?php wp_head(); ?>
    </head>
    <body>
    
    <div id="site">
    <div id="header"><a href="index.html"><img id="logo" src="/wp-content/themes/MaybeMarquis/images/marquis-logo.gif" width="203" height="52" alt="Marquis Energy"></a>
    			<div id="nav"><ul class="navigation">
    				<li class="navigation"><a href="energy.html" class="grey-green">ENERGY</a></li>
    				<li class="navigation"><a href="manage/index.html" class="grey-blue">MANAGEMENT</a></li>
    				<li class="navigation"><a href="grain/index.html" class="grey-orange">GRAIN</a></li>
    				<li class="navigation last"><a href="marine/index.html" class="grey-lightblue">MARINE</a></li>
    			</ul>
    			</div>
    			<div class="right"><ul class="navigation"><li class="navigation"><a href="contact.html" class="grey-white">CONTACT</a></li><li class="navigation"><a href="careers.html" class="grey-white">CAREERS</a></li><li class="navigation last"><a href="/wp-content/themes/MaybeMarquis/press.php" class="grey-white">PRESS</ul></div>
    		</div>
    <!--Navbar start-->
    
    <div class="topnavigationArea">
    
    </div>
    
    <!--Navbar end-->

    index.php (Works :: Location: wp-content\themes\MaybeMarquis\)

    <?php get_header(); ?>
    <script src="js/swfobject.js" type="text/javascript" language="javascript" ></script>
    <script src="js/swfs_divs.js" type="text/javascript" language="javascript" ></script>
    
    <div class="contentArea">
      <div class="container">
        <div class="contentLeft">
        <div id="swf-globe-plain"><img class="middle" src="wp-content/themes/MaybeMarquis/images/globe-plain.gif" width="350" height="350" alt="globe"></div>
        </div>
    
        <div class="contentRight">
    
        <?php
    $args = array( 'numberposts' => 2, 'category' => 6,);
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
    	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    	<?php the_content(); ?>
    <?php endforeach; ?>
        </div>
      </div>
    
    </div>

    press.php (everything has gone to hell! :: Location: wp-content\themes\MaybeMarquis\)

    <?php get_header(); ?>
    <script src="js/swfobject.js" type="text/javascript" language="javascript" ></script>
    <script src="js/swfs_divs.js" type="text/javascript" language="javascript" ></script>
    
    <div class="contentArea">
      <div class="container">
        <div class="contentLeft">
        <div id="swf-globe-plain"><img class="middle" src="wp-content/themes/MaybeMarquis/images/globe-plain.gif" width="350" height="350" alt="globe"></div>
        </div>
    
        <div class="contentRight">
    
        <?php
    $args = array( 'numberposts' => 2, 'category' => 10,);
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
    	<h2><a>"><?php the_title(); ?></a></h2>
    	<?php the_content(); ?>
    <?php endforeach; ?>
        </div>
      </div>
    
    </div>
  2. videovillain
    Member
    Posted 3 years ago #

    The best I can tell you is try to go to your:

    yoursitename/wp-admin/index.php

    and do an update to 3.2 (I suggest automatic).

    The reason I say this is that I recently updated to 3.2 and then my hosting site sent me a message saying I needed to get the new wordpress update. Not paying attention, I did the update from my hosting site (which actually was a downgrade to 3.14) and I ended up getting a very similar (if not the same) error message.

    If you do updates on the admin site, DON'T DO UPDATES on the hosting site... is the moral of the story, lol.

    Hope this helps!

  3. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Are you trying to load press.php directly? as in mydomain.com\wp-content\themes\press.php or something?

    If so, that won't work. You can't load template files directly.

    If not, how are you trying to load the template file?

  4. empulse
    Member
    Posted 3 years ago #

    Chip: I am. . . I guess this is where my problem exists... Again, keep in mind I have very little clue what I'm doing (my apologies!), but I assumed I could link directly to ie: mydomain.com\wp-content\themes\press.php

    My knowledge is basic html where <a href="/wp-content/themes/MaybeMarquis/press.php" class="grey-white">PRESS</ul></div> would work. . . . How would I go about to linking to press.php from my index.php??

  5. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    How would I go about to linking to press.php from my index.php??

    You don't.

    The Theme template files simply define how content is presented. The content itself is created within WordPress.

    I'm guessing that what you really need is for press.php to be a custom Page template.

    Then, you simply need to create a static Page, and assign your custom Page template to that static Page.

  6. empulse
    Member
    Posted 3 years ago #

    Chip,
    I feel like an idiot. Of course! I appreciate your assistance and lack of ridicule.

    Thank you kindly!
    Brandon

  7. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    No worries. :)

    We were all beginners once!

Topic Closed

This topic has been closed to new replies.

About this Topic