Site logo

Archived topic

different content-single.php pages

5 replies · Started by Kevin on August 1, 2022

Viewing posts 1–6 of 6

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
Kevin

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.

Hi Fernando,

because i need two different post templates.

If i create a new content-single.php, i have only one templates.

Hi,

no. I only use posts, no custom post type.

I need two different post templates, which I can then select in the post.

Post

One for normal posts and for the other I would like to add some more infos.

Ok, so slightly different.
Try the following:

1. Copy the single.php to your child theme and rename it single-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.php to your child theme and rename it content-single-post.php

Thats 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.

This archived topic is closed to new replies.