Site logo

[Support request] different content-single.php pages

Home Forums Support [Support request] different content-single.php pages

Home Forums Support different content-single.php pages

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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
    Kevin

    #2300283
    Fernando
    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.

    #2300946
    Kevin

    Hi Fernando,

    because i need two different post templates.

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

    #2301718
    David
    Staff
    Customer Support

    Hi there,

    i assume you registered a custom post type for your new single-post templates?

    If so, where you register your register_post_type function in the supports parameter array, add comments

    https://developer.wordpress.org/reference/functions/register_post_type/

    #2302171
    Kevin

    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.

    #2302214
    David
    Staff
    Customer Support

    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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.