Creating custom page layouts with WordPress

Posted on 01/05/10, in WordPress, by kevin

If you are using WordPress to create a website, and you want to avoid it looking like a blog, then you need to look at creating custom pages.

The ‘page.php’ file displays your generic page content using this template. You could customise this page to make it look as you want and set it as the home page in the WordPress admin screen. But what happens if we want to create a contact form section? or maybe a one off page that contains some bespoke code? This is how you do it…

In your theme folder, create a new file. In this example, I’ll call it custom.php. Now insert the following code to it.

<?php
/*
Template Name: Custom Page Layout
*/
get_header(); ?>;

// enter your code here

<?php get_footer(); ?>

Now with that, create a new page in the admin section and on the right where it says “Attributes”, select the template name you wrote in the custom.php (Custom Page Layout in this case).

Easy :-)

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogosphere News
  • DZone
  • email
  • LinkedIn
  • MySpace
  • PDF
  • RSS
  • StumbleUpon
  • Twitter

One Response to “Creating custom page layouts with WordPress”


Nimit Kashyap
3-14-2010

this is going to be really helpful for me… thanks

Leave a Reply