Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Create a Custom Page in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Create a Custom Page in WordPress

Do you want to create a custom page in WordPress? You might notice that many WordPress sites have different layouts for different pages. A custom page allows you to have different layout in appearance from regular pages in WordPress. In this article, we will show you how to create a custom page in WordPress.

Adding custom page template in WordPress

What is a Custom Page in WordPress

By default WordPress allows you to create posts and pages. Your WordPress theme controls the appearance of your pages by utilizing a template file called page.php.

This template file affects all single pages that you create in WordPress. However, not all pages are the same. Little changes in their layout and appearance can make them unique and a lot more useful.

Creating a custom page template in WordPress requires a basic understanding of HTML, CSS, and PHP.

Having said that, let’s jump into creating your first custom page in WordPress.

Creating a Custom Page in WordPress

First, you need to open a plain text editor like Notepad on your computer. In the blank file add this line of code at the top:

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

This code simply tells WordPress that this is a template file and it should be recognized as CustomPageT1. You can name your template anything you want as long as it makes sense to you.

Once you have added the code, save the file to your desktop as, custompaget1.php.

You can save the file with any name, just make sure that it ends with .php extension.

For this next step, you will need to connect to your website using an FTP client.

Once connected, go to your current theme or child theme folder. You will find it in /wp-content/themes/ directory. Next, upload your custom page template file to your theme.

Now you need to login to your WordPress admin area to create a new page or edit an existing one.

On the page editing screen, scroll down to ‘Page Attributes’ section, and you will find a template drop down menu. Clicking on it will allow you to select the template you just created.

Selecting your custom page template

Now if you change template and visit this page, then you will get to see a blank page. That’s because your template is empty and does not tell WordPress what to display.

Don’t worry, we will show you how to easily edit your custom page template.

Editing Your Custom Page Template

Your custom page template is like any other theme file in WordPress. You can add any HTML, template tags, or PHP code in this file.

The easiest way to get started with your custom page is by copying the existing page template provided by your theme.

Open your FTP client and go to your theme folder. There you will find a file called page.php. You need to download this file to your computer.

Downloading page template file

Open the page.php file in a plain text editor like Notepad, and copy all its content except the header part.

Template header of a typical page.php file in a WordPress theme

The header part is the commented out part at the top of the file. We are not copying it, because our custom page template already has one.

Now you need to open your custom page template file and paste it at the end.

Your custom page file would now look something like this:


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

<?php get_header(); ?>

<div id="primary" class="content-area">
	<main id="main" class="site-main" role="main">
		<?php
		// Start the loop.
		while ( have_posts() ) : the_post();

			// Include the page content template.
			get_template_part( 'template-parts/content', 'page' );

			// If comments are open or we have at least one comment, load up the comment template.
			if ( comments_open() || get_comments_number() ) {
				comments_template();
			}

			// End of the loop.
		endwhile;
		?>

	</main><!-- .site-main -->

	<?php get_sidebar( 'content-bottom' ); ?>

</div><!-- .content-area -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>


Save your custom page template file and upload it back to your theme folder using FTP.

You can now visit the page you created using custom page template. It will now look exactly like your other pages in WordPress.

You can now continue editing your custom page template file. You can customize it in any way you want. For example, you can remove the sidebar, add custom PHP code, add any other HTML you want.

You can add the content by editing the page in WordPress page editor screen. You can also leave the content area in page editor completely empty, and add custom content directly in your page template.

We hope this article helped you add a custom page in WordPress. You may also want to see our list of the best drag and drop page builder plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. Ajay says:

    Hi great tutorial!

    One question… I am adding new HTML template files that use css and js files etc. How can I link these files in my template file? I added the files to the same directory as the other stylesheets and assets but no luck. They do not render on the new template page. Any ideas?

    Thanks!

  2. The Last One says:

    Im confused.. i hink this site has written years ago, but if i do understand it, you cannot do custom pages anymore in wordpress unless you have some sort of subscription?

    i was trying to “edit” my wordpress site but all feature was missing.

  3. Rob says:

    Thanks – once again – how to remove header/footer/sidebar?

    Thanks

  4. Jeff says:

    thanks great help :)

  5. Deepan says:

    Thanks for this tutorial,this tutorial help me to understand the concept easily.Good Work keep continuing like this.

    -Deepan

  6. tony kh tan says:

    Thank you for this tutorial. I use cPanel to add the customPage.php onto wp-content/.. and it works. Without using FTP.

  7. Njoroge Mathu says:

    Thanks for the great article. Tried the steps and it works perfect. Seems like the file ‘CustomPageT1.php’ has to always be uploaded into the active theme folder or if working offline with wamp save it in wamp/www/wordpress/wp-content/themes/active theme.

  8. Amit Prasad says:

    Great Article. Exactly what I was looking for. Keep up the good work pal!

  9. Osvaldo says:

    This article, pure and simple, works like charm to me!!!

  10. Jean-Charles de Geekarts says:

    So it works perfectly bur when I put the file in a plugin file (because it make more sense) it doesn’t work. Do you have anyidea on what to do to make it work.

    Thanks anyway for all your great tutorial

  11. Ronny says:

    Great work, guys. Thank you very much. But one question please… How do i make this custom template pull posts from one particular category or categories? I’ve been building websites with wordpress for a while now but, this one seems knotty to me. I know there’s a plugin that does this, but I’ll rather go with the custom template method. Thanks, again…

  12. Chadly says:

    hey guys, is their a plugin you recommend for WP that creates great looking pages like this:

    You know, the pages that have the arrows pointing to things and almost a hand drawn look about the page.
    Thanks…

  13. irfan says:

    Sir my websites homepage is in the form of custom link in wordpress menu and is not present in all pages also.I am a totaly newbie in website development so kindly help to convet this custom link into a page.
    2:kindly also help to remove read more from posts.

    Thanks
    Irfan
    website Address:www.fishysms.com

  14. karlonc says:

    Does this tutorial still apply to the newest wordpress?
    Also will it keep any of the attributes of the theme you are using?

    • WPBeginner Support says:

      Yes, it applies on latest WordPress and will keep all attributes of the theme you are using.

  15. Musarrof says:

    Please give details more and write it easily with screenshot. new word-press user cant understand your reading tutorial.

    • WPBeginner Support says:

      Thanks for your feedback. Please let us know which part you did not understand and we will try to explain it.

      • Carol H. says:

        I didn’t understand this part…

        Once you have completed editing this file save it and upload it in your theme directory (/wp-content/themes/yourthemedirectory/) where files like single.php and index.php are located.

        How does one upload to one’s theme directory? (I have a wordpress.com site; does this have anything to do with this?)

  16. vinay says:

    Hi,
    where do we find the pages that were created with the add-new page link in wordpress.could someone help me out to figure out the pages.Thanks in advance

  17. Joanna Gasdogas says:

    oops. please ignore previous note.

    Thank you for these instructions.

    I have followed all your instructions, I believe correctly. However when I go to my WP editor to add content to this new template, nothing shows up on the page. It remains as a completely blank page.

  18. Joanna Gasdogas says:

    Thank you for this. I followed all the instructions. I have a blank template now. But when I go to my wp editor to add content, the content doesn’t appear in the new page.

  19. Marow95 says:

    How can I change the url ?
    I mean instead of “blog/?page_id=2” , I want it to be “blog/about” .
    Thanks in advance :)

  20. Kikky says:

    hallo, thanks for the post on creating a custom template, its helped greatly. But i have some issues i need answers to, this is my first time at wordpress and on the site i’m creating, i already have a custom template as the home page and then i have another page (with the theme’s initial homepage look, which is a custom page). the challenge i’m having now is : i want the custom template page i designed to load first but the theme’s custom page keeps coming up instead. i figured there’s some sort of conflict going on since they both have thesame url …so, preeeetyyy please, how do i get through this huge problem…thanks

    • WPBeginner Support says:

      Seems like you resolved your problem. In this case, you could have specifically told WordPress to use a template for a specific page. For example if you wanted to create a custom template for http://www.example.com/home-2 then you name your template file to be page-home-2.php. You can also use a page’s id in the template, like page-33.php will only work on page with 33 as the unique id.

  21. Pol Alvarez says:

    Hi! I have always coded my webpages from scratch but now I need to add one to a wordpress website. I mean I have good html/css and this kind of stuff but little of wordpress.

    I have followed the instructions and succesfully uploaded the file. The problem is that it is not listed on the template dropdown. I am not sure whether this happens because the file I created is not valid or any other problem. My file is composed of your header

    and then following it a normal webpage (opening with etc…) without any styles now external files (just to check it out).

    What am I doing wrong? any help would be appreciated.

    Thanks you are my last resort!

    • WPBeginner Support says:

      Pol, we can provide you some tips to troubleshoot.

      Please study the file page.php in your theme’s directory. Your custom page template should follow the same structure as page.php except the header part where you need to insert your own template name so that it can distinguished.

      Make sure that you have uploaded your template to the right directory. It should be in /wp-content/themes/your-theme-name/ folder.

      Let us know if this helped.

  22. Ansar says:

    I have a problem with this.when i add new page there is no option of template in page attributes. I’m using wordpress 3.8.1
    And also what is the name given to the page we are newly creating

  23. ReNet says:

    This is Great! BUT HELP!
    I created a template that pulls in a form, I currently have it with a Captcha but want to remove the captcha and use WordPress’ password protect functionality for this page so I can speedup multiple form entries.

    The issue is that WordPress displays the template’s content before entering the password.

    Your help would be greatly appreciated.

    • WPBeginner Support says:

      ReNet, thats because the password protect functionality implements password on the contents of the post/page that is protected not on your template. So the form you want to hide should be executed inside the post. You can create a shortcode for that and add it to your post/page.

  24. Sean says:

    Thanks for this – who knew it could be so simple!

  25. Troy says:

    Ok so I think Im missing a step or two…
    1) I opened up a blank text document, copied this “1” into the first line of the notepad

    2) Saved it to my desktop and loaded it into the proper wp-admin//themes/mythemedirectory/

    3) Got it to show up on wordpress. Then I copied and pasted my html code for my splash page that I created in dreamweaver into the text(html) portion on wordpress.

    4) Saved it as a draft and when I previewed it I get a bunch of strange text.

    Can you explain to me what steps am I forgetting or missing. I think its something with the other php markups? or maybe where I post my html code. Im looking to have splash page without any menus or anything else besides my splash page coding. Any help or assistance would be greatly appreciated. The information you provided has gotten me farther then any of the other blogs Ive looked at so thank you very much!

    • WPBeginner Support says:

      It seems like you are trying to design a page in Dreamweaver and trying to import it in WordPress. This will not work. Because your page already has a structure and style defined by your WordPress theme.

      • Troy says:

        thanks for the reply. Can I just take the html body from dreamweaver and paste it into the theme?

        • WPBeginner Support says:

          No it will still have the similar effect.

        • Surya says:

          You can do that but try pasting the code in notepad first and then copying it again to WordPress. This usually eliminates some unwanted things like DOM.

  26. niharika says:

    I have one question please……………. help me. I want to store marks of student in Mysql database and once user go to the result page he has to enter his roll no and class, then he see his result. I have done this project but I really don’t know how to go through it in wordpress i.e where to write html and php coding in wordpress.
    I am using WordPress.org on my localhost.

    • WPBeginner Support says:

      For that you will have to create your own custom solution using Custom Post Types, Custom Fields, and User Meta Data. If you look around you might find some WordPress plugin that already does all that.

  27. Andrea says:

    Thanks for the post – this was exactly what I was looking for, and so helpful!

  28. Stuart Alsop says:

    Thank you sooooo much for this tutorial. solved a big headache for me! Keep up the good work!

  29. Darren says:

    This page is fantastic! Thank you! I was messing around a little (a lot) with plugins when I did a search, came across this page, and figured this is way better than the other methods I was looking at to do something.

    One thing is that in the article, it isn’t immediately obvious that the code should be put on the page before being uploaded. I mistook it as inputting the code on the ‘add a new page’ text box. Second time I tried it, I stuck the code in the text file (also, it isn’t obvious that they should choose all files, and change the text file extension to .php), and it worked like a charm. You can even add blog1 / blog2 / etc… to get multiple themes up there if you so need.

    Thank you!

  30. Tim Reeves says:

    THANK YOU SO MUCH!!!!!!!!!!!!!!!!!!!!!!!!!! I have been trying to figure this out for 3 months now, came across your tutorial up and running with my new page template in 5 minutes.. I completely
    understand some of the comments above, as when you are first starting out everything is so confusing. But when you get a grasp of things it is so easy. AGAIN YOU ARE A LIFE SAVER,SCHOLAR,AND A GENTLEMAN !!!! : )

  31. lucas says:

    This is suppose to be for beginners? I can’t even pass the first step “You can start out by calling WordPress header and footer”
    what does it mean? whoever wrote this article has forgotten that is writing for beginners who tend to be clueless.
    I tried to call header and footer but nobody answer, maybe i got the wrong number.
    A screen shot will be quite useful.

    • Editorial Staff says:

      I think you misunderstood the site. WPBeginner caters for beginners of all level. This article is in the Themes category, and this is for beginner theme designers. The article clearly says that you need to have HTML / CSS knowledge before you can do this.

      We do have a beginners guide category – http://www.wpbeginner.com/category/beginners-guide/

      Instead of being really sarcastic, sending 2 separate emails and leaving a comment, you should consider being more polite. We do not get paid to write these tutorials. It is a kind gesture for the community, and many folks have learned from our site. It would be one thing to be pissed off, if you paid for something, and you didn’t receive it. This site is entirely FREE. We try to help as many folks as we can without charging a dime.

      -Syed
      Founder of WPBeginner

      • eduardo says:

        thaaaaannnksssssssss im a front end developer and i consider myself a wp beginner i found this article really helpful

  32. Markus Freeman says:

    I’ve tried this and it worked like a charm, but the there’s one problem. The Posts didnt show, only the sidebar. what could be the problem?

    Thanks,
    Markus

    • Editorial Staff says:

      That means that there is something wrong with the code in your template.

      • James says:

        I tried this too and like above only the sidebar shows. What could be wrong with the code in my template?

        • Joe says:

          Try copying the WordPress hook ( if statement) from the page.php file. Then paste it into the new file.

  33. Karla Porter Archer says:

    Thanks for this tutorial.

    I’m trying to do this in order to create the author page (http://www.wpbeginner.com/wp-tutorials/how-to-display-an-author-list-with-avatars-in-wordpress-contributors-page/).

    I’m using a child theme. Does this file get added to the main theme file directory or the child theme?

    • Karla Porter Archer says:

      I just tried it in the main theme and it finally showed. So I’m assuming the answer is ‘main theme’ and that I haven’t broken it :)

      • Editorial Staff says:

        No this file has to be added in the child theme directory. While it would work in the main genesis folder, it is best practice to never modify anything in the parent theme.

        • Karla Porter Archer says:

          ah – thanks — that was my original presumption, but it didn’t show the template as an option for the page, so I second-guessed myself. I obviously didn’t add it correctly then, so off to try again!

  34. Max Garcia Jr says:

    WITHLOVEASH31 posted a question on 10/24/2011. Could one of the Editor’s please respond. I’d really like to know. I could really use this feature. Thanks in advance!

    • Editorial Staff says:

      We didn’t reply because they also commented right after that they figured it out. You have to use FTP to login and upload a new theme file.

  35. LJSkool says:

    Completely newbie here. I was fine right up until you got to “begin creating a custom page by opening a blank file in your text editor”. Um, yeah…. Would that be the “editor” link under “Appearances” within my site? How do I “open” this? My purpose to have a page with all my blog posts on one page. My theme does not do this. Thanks!

    • Editorial Staff says:

      Hey Jackie,

      Yes this article does require prior HTML/CSS knowledge. Text Editor can be Notepad, Dreamweaver, Notepad++ etc.

  36. Ruth says:

    this is the first help page that’s helped me without creating another set of problems.
    It worked! I never built a php page before and I pasted everything in exactly
    Thank you!

  37. Taika says:

    “Since you have already written down all the text and settings in the php file, simply name the page and leave the content area blank”

    How to do that ? My WP does not allow me to leave the content blank, it requires to type something on title before it lets create/edit page name, then if I type something, name the page and remove the text leaving it blank and publish it publishes whatever I typed on title before I removed the text…any advice ? Thanks,

    Taika

  38. withloveash31 says:

    Oh never mind. I figured it out :)

  39. withloveash31 says:

    I was following your guide and everything went well until this- “upload it in your theme directory (/wp-content/themes/yourthemedirectory/) where files like single.phpand index.php are located.” This might stupid but how do i upload the file to my theme directory? I did find a page under the name “Editor” where single.php, index.php etc are located, i just don’t know how to upload the file i created. Please help :S

  40. nola says:

    Excellent! I thought this would be a hard process. You explained it simply. I still need to work out a few things with how my theme displays the custom template, but now I’ve learned something new. Thank you!

  41. saro.verhees says:

    Really awesome, exactly what i was looking for. Thanks

  42. scarab says:

    great post. This information was just what I was looking for. It took me about 40 minutes but I built a ‘squeeze’ page just like I wanted.

    I still need to do some of the header work but is minor in my opinion.

    Thanks

  43. Nina says:

    Brilliant!

  44. Alex Batista says:

    How to create a custom page in WordPress and put it how default?

  45. Frank says:

    freakin phantastic blog! This may be the best project site on the web…

  46. Marc Shaw says:

    Hey, I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say GREAT blog!…..I”ll be checking in on a regularly now….Keep up the good work! :)

    – Marc Shaw

  47. Missy says:

    Hi,

    I’m on here now trying to do this. Let me see if I can pull it off.

  48. MOMO says:

    Excellent tutorial. cheers guys.

    Momo

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.