So I was migrating a website I created using Sage and Wordpress for the first time. I ended up figuring most of it out through lots of troubleshooting and in the end, I thought I did everything correctly as my content loaded on my front page of Wordpress. However I was informed that this was the wrong way to do things and instead I should of:
Created a homepage.php file in the Templates folder and store my html for that page in that file.
Then created a base.homepage.php file in the theme directory with the base.php wrapper contents copied in it.
So I did this but when I go inside of Wordpress to assign my home page this template I do not see the template. I simply just see the “default theme” under template.
Can someone please explain in very laymen terms, if possible, what I am doing wrong? I’ve tried to Google this several times and do not understand the answer… please help me.
Page Templates require a PHP comment at the top with the name of the template:
<?php /** Template Name: Name of the Template */ ?>
Otherwise WordPress will not recognize them as templates. See the official documentation: https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-page-templates-for-global-use
2 Likes
THANK YOU!! THAT IS IT!!! THANK YOU!!!
WOW! I’m so relieved.
However, when I assign my page the template in Wordpress the contents of templates/homepage.php are not showing.
Am I missing something else? I apologize. I’ve read the documentation. A lot of it has went over my head.
I figured it out. I put
<?php
do_action('get_homepage');
get_template_part('templates/homepage');
?>
inside of my base.homepage.php file to grab the contents of template/homepage.php
Is this the correct way?
I don’t really understand what you’re attempting to do, or why you’re organizing it the way you are, so I don’t know how to answer that question.
If you’re not comfortable with WordPress and WordPress themes, I don’t really recommend starting with Sage—the design and documentation assume a certain level of familiarity with WordPress/WordPress Theme concepts.
If you want to see how a Sage 8 theme is roughly intended to be laid out, you can always take a look at a clean installation, or the theme git repo (at the 8.5.4 tag): https://github.com/roots/sage/tree/8.5.4