- This topic has 9 replies, 3 voices, and was last updated 1 year, 8 months ago by David.
-
AuthorPosts
-
August 7, 2022 at 9:38 am #2306014Budi
Hello,
In page attributes, I can only see Parent and Order.
Where I can find template in page attributes?Thanks.
August 7, 2022 at 7:27 pm #2306263Fernando Customer SupportHi Budi,
What exactly are you trying to do? There’s no template metabox in the settings of a page or post by default.
August 8, 2022 at 7:30 am #2306784BudiI want to create a custom page.
In other theme, I can see Template in page attributesAugust 8, 2022 at 7:50 am #2306945DavidStaffCustomer SupportHi 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-post3. 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
August 9, 2022 at 3:30 am #2307666BudiHello,
What is the url to show the custom page ?
Thanks.August 9, 2022 at 3:33 am #2307668DavidStaffCustomer SupportThere 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.August 9, 2022 at 5:38 am #2307739BudiHello,
Please check the result
August 9, 2022 at 6:05 am #2307761DavidStaffCustomer SupportDid you make copies of both files i told you too ?
August 9, 2022 at 7:04 am #2307821BudiYes, I have made changes.
Thanks.August 9, 2022 at 7:13 am #2307837DavidStaffCustomer SupportPlease 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.
-
AuthorPosts
- You must be logged in to reply to this topic.