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
1 Answer
Reset to default 0No 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
版权声明:本文标题:How do I change the template specifically for single posts? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741588280a2386969.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论