Page Template for Static Home Page
-
After a bit of googling and searching the forums and codex I am still perplexed. This is probably an intermediate level problem but the answer eludes me.
I created a page called “home” and set reading -> display static page using the page “home”. Next, I wanted to create a custom template for my home page. Here is what I have there, just copied from page.php, as test material, in the file called page_home.php:
<?php /* Template Name: Home Page */ ?> <?php get_header(); ?> <div class="row"> <div class="span12"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail('full'); } ?> </div> </div> <div class="row"> <div class="span8"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h1> <?php the_title(); ?> </h1> <div class="padding25"> <?php the_content(); ?> <?php endwhile; else: ?> <p> <?php _e('Sorry, this page does not exist.'); ?> </p> <?php endif; ?> </div> <div class="span4"> <?php get_sidebar(); ?> </div> </div> <?php get_footer(); ?>
Ok, all fine and dandy. So I go back to my “home” page and set the template to “Home Page”. I refresh my browser and there is no content between header and footer. I have two posts that show up on my posts page fine, not sure why they don’t show up using this template on the home page. You can literally replace the above code with gibberish and nothing happens to the page.
Is there something special you have to do to set a template for a static front page? Or is a static page by default unable to use a custom template, and you must enter the HTML directly onto the page itself?
- The topic ‘Page Template for Static Home Page’ is closed to new replies.