Archived topic
Can not find template in pages attributes
9 replies · Started by Budi on August 7, 2022
Hello,
In page attributes, I can only see Parent and Order.
Where I can find template in page attributes?
Thanks.
Hi Budi,
What exactly are you trying to do? There’s no template metabox in the settings of a page or post by default.
I want to create a custom page.
In other theme, I can see Template in page attributes
Hi there,
those are custom templates that theme authors can choose to add. GP does not add any.
But you can add your own, but it requires an understanding of PHP and HTML.
Heres a quick how to, with the aim of using copies of the GP Single Post Templates to create your own custom template.
1. First you must add a Child Theme to your site.
https://docs.generatepress.com/article/using-child-theme/
It is in the child theme folder that you will save your templates.
2. In the Parent GP Theme folder look for the following files and copy them to the root of your child theme, and rename them
File 1: single.php --> Rename this to eg. custom-post.php
File 2: content-single.php --> Rename this tocontent-custom-post.php
Note whatever you rename the single.php, eg. custom-post must also be the name at the end of your second file e.g content-custom-post
3. Edit your newly named content-custom-post.php in a text editor or IDE.
At the top of the template you will see this:
/**
* The Template for displaying all single posts.
*
* @package GeneratePress
*/
Replace it with:
/**
* Template Name: Single Post template
* Template Post Type: post
* @package GeneratePress
*/
You can set the Template Name to whatever you want.
The Template Post type sets which post type to offer the custom template eg.
* Template Post Type: post just for posts
* Template Post Type: page just for pages
* Template Post Type: post, page for posts and pages.
4. Make any changes you want to your new templates if you need to.
Thats it
Hello,
What is the url to show the custom page ?
Thanks.
There is no URL for the Template.
You create a post / page select your template, and you visit the URL for the post or page you created.
Hello,
Please check the result
Did you make copies of both files i told you too ?
Yes, I have made changes.
Thanks.
Please note: do not add code inside the Private Information field.
And are you happy with your changes ? as i cannot advise on how you build your own custom template.