Hello developers,
- Here I am going to show you how to easily create custom single post templates in WordPress without plugin.
- Sometimes you want different look in your posts of your websites.
- Custom single post templates allows you to select different templates for your posts.
- Please follow my below article.
- Make copy of single.php and give it name whatever you like.
- For e.g, I have made my-template.php file.
- Open it and copy below code in top section. Please check below code.
<?php /* * Template Name: My Template * Template Post Type: post */ get_header(); ?>
Now, copy all below content just after get_header(); ?> which is in single.php. Please check below code.
<div class="wrap"> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php /* Start the Loop */ while ( have_posts() ) : the_post(); get_template_part( 'template-parts/post/content', get_post_format() ); // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) : comments_template(); endif; endwhile; // End of the loop. ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); ?> </div><!-- .wrap -->
You can see in post template in admin section and select template. You will be able to select your template. You can see in below screenshot.
![](https://www.cloudweblabs.com/wp-content/uploads/2019/12/output.png)
Hopefully this article useful for you.
Thank You 🙂