user894932
user894932

Reputation:

Wordpress php function get_header and get_footer issue on IIS7.5 & localhost

I have installed IIS7.5 on my box for development including php of course, and i have copied my wordpress site from my live server and changed the url settings in the db etc.

however when visiting the homepage none of the style or meta data associated in the header.php file is rendered. looking at the source code it changes the default php function

        <?php get_header(); ?>

to include the header.php file and it gets rendered to the browser as

        <? get_header(); ?>

i.e it is viewable as such in the view source.

other php functions and includes and php generally seems to be running ok in other files... i have mantisBT install running smoothly for example.

Does anyone have any ideas what might be causing this?

ta

EDIT: adding index.php file - very vanilla.

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

         <!-- Begin Post: <?php the_title(); ?> --> 

            <div class="post">
            <h3 class="posttitle"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
            <div class="title"><div class="postmetadata"><?php the_time('F jS, Y'); ?> by <?php the_author(); ?> in <?php the_category(', '); ?></div></div>

            <div class="entry">
                <?php the_content(); ?>
            </div>

<div class="tags"><div class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?></div></div><div class="comments"><div class="postmetadata"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> <img src="<?php bloginfo('template_directory'); ?>/images/comment.png" alt="Comments" /></div></div>
            </div><br /><br /><br /> 

         <!-- End Post: <?php the_title(); ?> -->

         <?php endwhile; ?>
            <div class="navigation">
                <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
                <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
            </div>

         <?php else: ?>
          <p>Sorry, no posts matched your criteria.</p>
         <?php endif; ?>

         </div>
         <!-- Include Sidebars -->
         <?php include (TEMPLATEPATH . '/sidebarR.php'); ?>
         <?php include (TEMPLATEPATH . '/sidebarL.php'); ?>     
         </div>
         <?php get_footer(); ?>

EDIT: added header.php - also pretty vanilla

     <!DOCTYPE html>
     <html>
     <head>
     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />    
        <link href="style.css" rel="stylesheet" type="text/css"/>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_head(); ?>
<title><?php if (is_single() || is_page() || is_archive()) { ?><?php wp_title('',true); ?> | <?php } ?><?php bloginfo('name'); ?></title>
     </head>
     <body>
     <div id="navwrap">
     <div id="nav">
        <div class="navpad">
            <ul class="navi">
     <li class="page_item"></li>
        </div>
     </div>
     </div>
     <div id="header">
        <div class="headpad">
             </div>
     </div>
     <div id="wrapper">
     <div id="content">

UPDATE: still getting the same issue, have reinstalled php 5.3.8, checked encoding, saved files as utf-8 without BOM. still no joy.

           <? get_header(); ?>



              <div class="post">

UPDATE 2:

Still not got this to work, the code is standard for a wordpress theme, i've installed another theme and it seems to work ok, so i doubt it is a IIS7 issue.

i've looked at the encoding of files and made sure everything is utf-8.

all my wordpress core files are intact and up to date.

Upvotes: 0

Views: 2861

Answers (4)

user894932
user894932

Reputation:

it appears a number of issues helped fix it to a certain extent...

  1. removed ~ from folder name in path.
  2. added test.xyz.com addresses to host file
  3. added these addresses to II7.5
  4. updated wordpress db to reflect the new addresses.
  5. rewritten index.php of theme file and rewritten the call to the get_header function.
  6. wasted too much of my life on this...

result:

  1. localhost/path/to/index.php now works and loads the header as expected. but not all the content (page not found on homepage).

  2. test.xyz.com/index.php doesn't load header and still shows <? get_header(); ?> and the equivalent for the footer file.

Upvotes: 0

Vasanthan.R.P
Vasanthan.R.P

Reputation: 1287

Instead of <?php get_header(); ?> try the direct include method <?php include_once("header.php"); ?> and let me know what happend.

Also <?php get_footer(); ?> works correctly or it is also displays in the source code. Thanks

Upvotes: 1

Drahkar
Drahkar

Reputation: 1671

If you are not using any <?xml ?> in your code, then you might try adding short_open_tag 1 to your php.ini. It looks like you environment might be stripping the php from the tag <?php and if you are using PHP 5.3+ short_open_tag is disabled by default and won't render.

The preference is to have short_open_tag disabled, and it would be worth looking to find out what the php is bring removed from the <?php, but setting the configuration setting to 1 might at least get it working for now.

Upvotes: 1

brokedid
brokedid

Reputation: 899

This Row in the Wordpress Template File is a php code, which should be processed on server-side, it shouldn't be visible in the Source Code when you're calling the Page with IIS

  <?php get_header(); ?>

Check your php installation and rewrite the PHP-Open Tag <?php and the PHP-Close Tag ?> manually. There can also be an encoding issue between the Tags. Also try do edit the document with another editor, or try to change the Encoding Type to UTF-8. If it still fails then attach your Template header.php here.

Upvotes: 1

Related Questions