WordPress front-page.php template

I have my front page set to a static page and am trying to build my custom template. How do I actually show the selected front page in front-page.php? I have googled and googled but can’t seem to figure out how to do it.

The front-page.php actually loads like it should, but I can’t seem to find documentation on exactly how to show the page that is assigned as the static home page. Any suggestions?

Read More

I have tried

<?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( 'content', 'page' ); ?>
    <?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>

but that didn’t seem to work…

Related posts

Leave a Reply

4 comments

  1. Your static page uses a page template (usually page.php for the default template)

    You can create a new one for the homepage if you wish. see : Creating_Your_Own_Page_Templates copy page.php to homepage.php and change the template name

    Example template (homepage.php) :

    <?php
    /*
    Template Name: Homepage
    */
    
    //the content of page.php and now you can do what you want.
    ?>
    
  2. $id = 0; /* The id of your page */
    $page = get_page($id);
    echo apply_filters('the_content', $page->post_content);
    

    If its a static page, I should not use a loop.

  3. I was missing something obvious. The loop I was using I had copied out of wordpress template. It actually called another template file. What I should have used was:

    <?php while ( have_posts() ) : the_post(); ?>
                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <header class="entry-header">
                        <h1 class="entry-title"><?php the_title(); ?></h1>
                    </header>
    
                    <div class="entry-content">
                        <?php the_content(); ?>
                        <?php wp_link_pages(array('before' => '<div class="page-links">' . __('Pages:', 'twentytwelve'), 'after' => '</div>')); ?>
                    </div><!-- .entry-content -->
                    <footer class="entry-meta">
                        <?php edit_post_link(__('Edit', 'twentytwelve'), '<span class="edit-link">', '</span>'); ?>
                    </footer><!-- .entry-meta -->
                </article><!-- #post -->
    <?php   endwhile;?>