admin管理员组

文章数量:1293984

My goal is that when someone clicks on a post, the page they are taken to has no sidebar cluttering the view. I want them to focus on the content. I only want the sidebar to appear on the homepage, which in my specific case is the page where all posts are loaded in order. All static pages on the site have customization options in Wordpress' page editor, so my only issue is the page that appears after you click "Continue Reading"

I'm using Wordpress' "Period" theme as the parent, and editing in a child theme. The template I want to apply to all single posts is Period's "Full-Width" template. There is no single.php file in the Period theme, so I created one in my child theme. I already tried duplicating the template into my single.php file, but that didn't change anything.

Does anyone have any suggestions? Here is my website (it's definitely not finished yet): /

And here is my single.php code:

    <?php
    /*
    ** Template Name: Full-width
    */
    get_header(); ?>
    <div id="loop-container" class="loop-container">
        <?php
        if ( have_posts() ) :
            while ( have_posts() ) :
                the_post(); ?>
                <div <?php post_class(); ?>>
                    <article>
                        <?php do_action( 'page_before' ); ?>
                        <?php ct_period_featured_image(); ?>
                        <div class="post-container">
                            <div class='post-header'>
                                <h1 class='post-title'><?php the_title(); ?></h1>
                            </div>
                            <div class="post-content">
                                <?php the_content(); ?>
                                <?php wp_link_pages( array(
                                    'before' => '<p class="singular-pagination">' . esc_html__( 'Pages:', 'period' ),
                                    'after'  => '</p>',
                                ) ); ?>
                                <?php do_action( 'page_after' ); ?>
                            </div>
                        </div>
                    </article>
                    <div class="comments-container">
                        <?php comments_template(); ?>
                    </div>
                </div>
            <?php endwhile;
        endif; ?>
    </div>
    <?php get_footer();

Thanks in advance for the help!

My goal is that when someone clicks on a post, the page they are taken to has no sidebar cluttering the view. I want them to focus on the content. I only want the sidebar to appear on the homepage, which in my specific case is the page where all posts are loaded in order. All static pages on the site have customization options in Wordpress' page editor, so my only issue is the page that appears after you click "Continue Reading"

I'm using Wordpress' "Period" theme as the parent, and editing in a child theme. The template I want to apply to all single posts is Period's "Full-Width" template. There is no single.php file in the Period theme, so I created one in my child theme. I already tried duplicating the template into my single.php file, but that didn't change anything.

Does anyone have any suggestions? Here is my website (it's definitely not finished yet): https://thoughtversation/

And here is my single.php code:

    <?php
    /*
    ** Template Name: Full-width
    */
    get_header(); ?>
    <div id="loop-container" class="loop-container">
        <?php
        if ( have_posts() ) :
            while ( have_posts() ) :
                the_post(); ?>
                <div <?php post_class(); ?>>
                    <article>
                        <?php do_action( 'page_before' ); ?>
                        <?php ct_period_featured_image(); ?>
                        <div class="post-container">
                            <div class='post-header'>
                                <h1 class='post-title'><?php the_title(); ?></h1>
                            </div>
                            <div class="post-content">
                                <?php the_content(); ?>
                                <?php wp_link_pages( array(
                                    'before' => '<p class="singular-pagination">' . esc_html__( 'Pages:', 'period' ),
                                    'after'  => '</p>',
                                ) ); ?>
                                <?php do_action( 'page_after' ); ?>
                            </div>
                        </div>
                    </article>
                    <div class="comments-container">
                        <?php comments_template(); ?>
                    </div>
                </div>
            <?php endwhile;
        endif; ?>
    </div>
    <?php get_footer();

Thanks in advance for the help!

Share Improve this question edited Apr 26, 2021 at 20:53 Jonathan Wilson asked Apr 26, 2021 at 20:46 Jonathan WilsonJonathan Wilson 11 bronze badge 1
  • please ask in your theme's forum at wordpress/support/theme/period – Michael Commented Apr 26, 2021 at 22:36
Add a comment  | 

1 Answer 1

Reset to default 0

No custom template is necessary.

Copy sidebar-primary.php to your child theme. Change first line to:

if ( is_page_template( 'templates/full-width.php' ) || is_single() ) {

Go to Customize -> Additional CSS, and add:

.single-post #main {
  width: 100%;
  float: none;
} 

Done.

本文标签: How do I change the template specifically for single posts