WordPress – Create a landing page template within your theme that has no navigation

I thought this will be a nice little guide on how you can create a page template inside your theme to assign to pages that you want to use as a landing page.

Landing pages have become an extremely powerful tool in the world of marketing to test different ideas about products and engagement. A landing page is simply

A page that has no menu or sidebar, i.e. any distractions that would lead the user away from the page. It goes from top to bottom and each part of the page gives more information about the subject the page is designed for. Normally a landing page has a call to action at the bottom which can be a button, a subscription form or a “buy now” link.

Now that we know why you would want a landing page, lets find out how to create a new page template for your existing theme.

Creating the template

Before we get the template, I want to stress that you really should be doing this in your child theme folder and not in your main theme folder. If you don’t know what the difference is then please check this page.

Now, in your main theme folder you will have a /main-theme/page.php file. Copy it across to /child-theme/page.php. Then rename the file to /child-theme/page_landing.php. If you are not sure about the naming of files and why it is using a “_” instead of “-” please read this article. In my example the page_landing.php looks like this:

/child-theme/page_landing.php

Notice at the top we have a template name. This name will be shown in the WordPress page admin, so it should make sense. I’ve named mine:

If you go to the page admin on the page that you want to become your landing page on the side you would most likely see:

Screen Shot 2016-02-26 at 17.02.46

If you click the “Template” drop-down the “Landing page” should be there. Select it.

Screen Shot 2016-02-26 at 17.02.58

The header

Now, if you refresh the page it should look no different to what it was before (a lot of work for nothing??). Please bare with me. What just happened is that now we have our own page template and we have absolute control over that page and how it looks.

Most of the page should be as it is, we can edit the content from the admin, but what we want now is to remove the navigation from the header. For this go to /main-theme/header.php and copy it over to /child-theme/header.php. Now rename the file to /child-theme/header-landing.php. Edit the file and remove the code for the navigation, this is how it looked for me before and after:

/child-theme/header-landing.php BEFORE:

/child-theme/header-landing.php AFTER:

Nice, if you refresh the page now though you would still see the menu! Why? Because our page_landing.php doesn’t know about the existence of header-landing.php. Go back to the /child-theme/page_landing.php and change:

to

Notice we have the get_header( ‘landing’ ); ?>. This tells our new landing page to use the updated header. Save and do a refresh, now you should have no navigation in your header and you can continue working on the content of your landing page.

Moreover, editing those two templates you can adjust any other styling, add HTML and make any changes you wish to tailor the way your landing page looks. Also, you can re-use the template by assigning it to any new pages from the:

Screen Shot 2016-02-26 at 17.02.58

I hope that helps, if you have any questions, please write in the comments below.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *