Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have the following code for a page. When I select the template Home Page from the drop down menu in the page edit, it doesn't work on my web host, but locally it works fine, so I don't think it is my code. I don't know why its not working though.

<?php
/*
Template Name:Home Page
*/
?>
<?php get_header(); ?>
test
<div class="row">
    <div id="welcome" class="seven columns centered">
    <?php 
        $page_id = 2; 
        $page_data = get_page( $page_id );
        $content = apply_filters('the_content', $page_data->post_content);
        echo $content;

    ?>
    </div>
</div>
<?php get_footer(); ?>
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Might be a difference in query methods. This is a simpler way to query a page's content and can be used multiple times in a template without each query conflicting with each other.

<?php $my_query = new WP_Query('page_id=2'); ?>

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

<?php the_content(); ?>

<?php endwhile; ?>
share|improve this answer
    
This seemed to work. It also fixed it self when I renamed the home.php file to something else, not sure why that would be. –  Anders Kitson Mar 14 '12 at 3:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.