0

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(); ?>

1 Answer 1

1

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; ?>
1
  • 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. Commented Mar 14, 2012 at 3:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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