Post Templates: get_template_part in a Child Theme
-
What I’m trying to do is create a new page template with no title and header area to use on the static front page, and perhaps use on other pages. I’m customizing TwentyTwenty via my own child theme (but I don’t think my issue is theme specific and I can’t seem to post in the theme support forum anyway, so I’m here)
I’ve created a template-noheader.php page in a templates folder for my child theme with the comments at the top so it comes up as an option when I’m editing the page.
This seems to work, text I add on this page to test it appears on my site.
The problem is when I try to call the template part content-noheader.php within the template. I’ve based this off of the templates with the twentytwenty theme and plan to edit it. But text I put on this page doesn’t appear on my site.
File structure: templates/template-parts/content-noheader.php
I tried this first: get_template_part( ‘template-parts/content-noheader’);But found that it didn’t display any of the content – so the page consisted of the site header and the footer.
When I was searching around for a solution I came across this syntax:
get_template_part( ‘template-parts/content’, ‘noheader’ );At first I thought this had worked, but when I started to edit content-noheader.php the changes didn’t appear, so I think it is still pulling the parent theme’s default content file.
I’ve tried assigning the template to the about page as well just in case the the index.php in the parent theme was overriding. But it doesn’t work there either.
I know I’m probably missing something as I haven’t played around with page templates before. I’ve previously removed titles with css but I also don’t want the area it would appear in to be displayed at all and having a template that I could choose to use on other pages seemed to be a neat solution.
Any pointers would be appreciated.
The page I need help with: [log in to see the link]
- The topic ‘Post Templates: get_template_part in a Child Theme’ is closed to new replies.