Wern Ancheta

Adventures in Web Development.

Quick Tip: How to Add Custom Pages in Wordpress

| Comments

In this quick-tip I’ll be showing you the easiest and quickest way to create custom pages under a specific theme in Wordpress. When I say custom, its a page where you can put anything you want using HTML, CSS, JavaScript and PHP Code. The page would also have access to the various APIs that Wordpress provides.

To start, create a new file under your theme folder. In this case I’ll be creating a custom-page.php file under the wp-content/themes/twentyfifteen directory of my Wordpress installation. Then add the following code in the file:

Template Name: My Awesome Custom Page
<h1>This is my awesome custom page</h1>

Yes, that’s all there is to it. Note that the Template Name: part is very important. You can assign any value that you want as long as its descriptive. This specific comment is used by Wordpress to recognize your file.

To assign this page to a specific Wordpress page. You can add a new page from Wordpress admin page and select the page that we have created under the Template drop-down:

custom wordpress page

Now when you access the page from your browser, you will get that awesome heading. From your custom page you can also use the methods available on all the Wordpress APIs and also the built-in theme functions such as the get_header and get_footer.