WordPress.org

Ready to get started?Download WordPress

Forums

Static front page template (5 posts)

  1. zaphan58
    Member
    Posted 2 years ago #

    I need to create a custom template for my static front page but not certain how to go about it. I have read the documentation and know how to create the template but in the template files list it mentions a template called front-page.php http://codex.wordpress.org/Theme_Development#Template_Files

    Is this what the template should be called or can it be named anything?

    Many thanks

  2. marketermatt
    Member
    Posted 2 years ago #

    Zaphan58,

    You can call it anything you want as long as you put the following at the top of the .php page:

    <?php
    /*
    Template Name: Snarfer
    */
    ?>

    You can check out the specifics here:

    http://codex.wordpress.org/Theme_Development#Custom_Page_Templates

    That help?

  3. cassihl
    Member
    Posted 2 years ago #

    You can also create a page called page-home.php and make sure to add this to the top of the file:

    <?php
    /*
    Template Name: home
    */
    ?>

    Then go to Pages > Add New and apply the 'home' page template to it.

    You can name a custom page template anything you want, just use the page-custompage.php format and include that bit of php at the top.

    Edit - looks like marketermatt beat me to it. ;)

  4. zaphan58
    Member
    Posted 2 years ago #

    Thanks guys!

    I have another question. I created the front page template as in the code below. But, within the page content it is displaying the comments link and posted on date etc. Comments are disabled and they don't show on other pages, just the fron page that uses this template. Does the loop or something need editing?

    <?php
    /*
    Template Name: Page - Front
    */
    get_header();
    
    ?>
    
    <div id="contentwrapper">
    
    		<div>
    				<p class="front-statement">
    					Unique text for the static front page.
    				</p>
    		</div>
    
    	<div id="content">
    
    			<?php
    			/* Run the loop to output the posts.
    			 * If you want to overload this in a child theme then include a file
    			 * called loop-index.php and that will be used instead.
    			 */
    			 get_template_part( 'loop', 'index' );
    			?>
    
    	</div><!-- close content -->
    	<?php get_sidebar(); ?>
    </div><!-- close contentwrapper -->
    <?php get_footer(); ?>
  5. zaphan58
    Member
    Posted 2 years ago #

    Actually, forget my last post. I just realised I was a retard and copied the index file and not the page file into the new page template.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.