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.
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.
No you can't link directly to a template file.
What you can do is either:
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.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.
There are two ways to approach this:
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.
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.