- This topic has 5 replies, 3 voices, and was last updated 3 years, 10 months ago by
David.
-
AuthorPosts
-
August 1, 2022 at 12:59 pm #2300164
Kevin
hello,
I am trying to create different post templates.first try
copied the content of single.php and pasted it into single-post.php. Unfortunately the content is in content-single.php, so this doesn’t work.second try:
I copied the content of content-single.php and pasted it into content-post.php. in single-post.php I rewrote the code “generate_do_template_part( ‘single’ );” into “get_template_part( ‘content-post’ );”. now it works, but the comment function is not displayed.You can help me?
Thank.best regards
KevinAugust 1, 2022 at 6:53 pm #2300283Fernando Customer Support
Hi Kevin,
Why not just overwrite content-single.php? Basically, create a new content-single.php in your child theme directory, and paste the contents of the original content-single.php there?
Let us know.
August 2, 2022 at 8:45 am #2300946Kevin
Hi Fernando,
because i need two different post templates.
If i create a new content-single.php, i have only one templates.
August 3, 2022 at 3:59 am #2301718David
StaffCustomer SupportHi there,
i assume you registered a custom post type for your new
single-posttemplates?If so, where you register your
register_post_typefunction in thesupportsparameter array, addcommentshttps://developer.wordpress.org/reference/functions/register_post_type/
August 3, 2022 at 8:24 am #2302171Kevin
Hi,
no. I only use posts, no custom post type.
I need two different post templates, which I can then select in the post.
One for normal posts and for the other I would like to add some more infos.
August 3, 2022 at 9:08 am #2302214David
StaffCustomer SupportOk, so slightly different.
Try the following:1. Copy the
single.phpto your child theme and rename itsingle-post.php
1.1 Edit the template and change its header from:/** * The Template for displaying all single posts. * * @package GeneratePress */TO:
/** * Template Name: Single Post template * Template Post Type: post * @package GeneratePress */2. Copy the
content-single.phpto your child theme and rename itcontent-single-post.phpThats it, in the editor you should be able to choose either template, and by default they will have the comments options you have enabled in Settings > Discussion and the editor discussion meta box.
-
AuthorPosts
- You must be logged in to reply to this topic.