0

I have created 2 pages inside wordpress "blog" and "hpage", on the config I have set static front page to "hpage" as initial page and "blog" for posts index.

Now I want to create a "page-hpage.php" file to create a really especific front page. Looking for the template hierarchy I see that I can use "page-$slug.php", but "page-hpage.php" just doesn't work but if I use "page-$id.php" using the id of the "hpage" I work.

Now, If I install this template again the page is likely to not have the same ID again, so it will fail. What I'm doing wrong?

  • Make sure that your page slug is actually called hpage. do var_dump( get_queried_object()->post_name ); in your header and check the result – Pieter Goosen Dec 28 '15 at 6:12
1

Use 'front-page.php' for your template. You can read more about it at https://codex.wordpress.org/Creating_a_Static_Front_Page

Or create a page template that you set in the editor. This will allow you to set it on any page and you're not tied to the ID.

https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/

<?php /* Template Name: Example Template */ ?>

Page Template

  • This means that there is no way to achieve what I want without using front-page ? – lcjury Dec 28 '15 at 3:09
  • Updated to include page templates without ID. – jgraup Dec 28 '15 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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