I have been searching for theme developing info but all that are related to this subject are talking about a custom page at page.php.

What I am trying to achieve is different. The scenario is that I have to create a page where the content is hard-coded, so I can have more creative freedom on the design. That is to say, I don't want to have it generated through adding pages from the CMS, since there are more restrictions to it.

Can I create a new static .php (a page.php with specific content), and linked to it from menu nav bar? It is similar to making a static home page, but not a "home" page.

3 Answers 3


No you can't link directly to a template file.

What you can do is either:

  1. Create a custom page template with your markup and content hardcoded into it. Then create a 'dummy' page in the back-end and assign the template to it. Then you can link to that page from the menu.
  2. Also create a 'dummy' page in the back-end, but instead of a custom template, create a page-{slug}.php template (where {$slug} is the slug of the page) with your markup and content hardcoded into it. Then when you view that page the page-{slug}.php will be used instead of page.php. Then you can link to that page from the menu.
  • so you mean: [1] Create a mypage.php + a blank page from admin panel using that template. That I understand the logic behind it. However I am a little bit confused with method [2]. [2] is indeed also creating dummy page, but edited the link so tricked wordpress to load a different template, right? what's the benefit of not using method[1]? since both methods will be creating blank pages in the backend?
    – adrian li
    Commented Jul 13, 2018 at 12:58
  • The benefit of method 1 is that you can see from within the back-end of WordPress what template is being used. Method 2 would require that you look at the theme files to know what's going on. And method 2 isn't 'tricking' anything, it's a supported method of creating page-specific templates. See here. In fact, read that whole page. Commented Jul 13, 2018 at 13:07

You can have all the freedom you want. First create a page in the database. Name it Example. Then create a file page-example.php.

<?php get_header(); ?>
<h1>Example page</h1>
<?php get_footer(); ?>

This is your specific template for the example page. Ommiting the get_header and get_footer will leave you with a blank page.

  • In what folder should the page-example.php be placed in? Commented Sep 22, 2021 at 8:32

There are two ways to approach this:

  1. You can write a complete html page and put it in a directory of your WordPress installation. You then link directly to that page. WP will treat it like an external link and of course you can put that link in your menu. This means the complete content is outside your installation, so it won't turn up in search either.

  2. You can write an almost empty template which only uses the_title and the_content to retrieve the data from the database (take into account the template hierarchy for naming of the template). You put all the content including the html in the content field. In this way the content is inside the database and will turn up in search.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.