Creating a Custom Page Template

May 6, 2008 · Print This Article

Sometimes creating a page within WordPress can be frustrating because it reformats the post and will sometimes break links or cause things not to display correctly. It can also be difficult to display videos or buttons within a page if you use the rich text editor built into WordPress.

One thing I typically do in these situations is to create a custom page template for certain pages where I need more control over how it displays.

Here is what you need to do. As a quick note, you will need some very basic HTML coding knowledge to write your page by hand, and you will want to make a backup of your theme before attempting this for the first time.

What I did was make a copy of the page.php file within my theme. That is because WordPress uses the page.php file when creating your themes pages. Rename the copy whatever you want, as long as it isn’t already in use (I just went with advertise.php in my situation). Now you will need to name the PHP file. Once that is done, go to the middle of the PHP file you’ve created and delete out the content code, which usually looks something like this:

<?php the_content(__('[Read more]‘));?>

This code might vary a little based upon the theme you are using, so it may not appear exactly like this. Now, you’ll want to paste the text/code you want to use on your custom page. Once you’ve got it how you want it, you’ll want to upload it to your site.

The next thing you need to do is to create a new page in your WordPress dashboard like you normally would. Once you’ve created a title, leave the rich text editor blank and go to the Page Template drop-down box in the right menu. Locate the named page you created earlier in the drop-down menu and select it. Now publish your page.

You’re done! Go check your site to see how it looks and make adjustments as needed.


Related articles:

  • No Related Post
Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.