Creating Single.php WordPress Post Layout

In this article, we are creating single.php WordPress post layout. This article will demonstrate you how to specify post layout for the WordPress post. So in this tutorial, we will show you how to set the template file of WordPress theme and make them more attractive. we will also learn why we want to use the single.php file in our WordPress theme.

In the previous video, we look out how we will build the WordPress website step by step. But in this article, we will look out post layout which is most important.

Creating Single.php WordPress Post Layout

This one really one of the simple post layout of WordPress.


Sometimes you want to select different look for your website. The single.php file will do the same thing for you it will give you a way to customize the post. Yes, you heard it right. The single.php file will use to customize your WordPress theme post as per your customization.

So when you change the single.php file it will not affect on index.php file. the single.php file is only affect to the post of the WordPress themes. if you want to change the layout of the post or if you want to change the font family, color, or anything that you do not want to apply to index.php file.

You can create the template file for customizing your post.

So first create Single.php file.

Make sure do not place this file inside of any folder. This is the WordPress template file so if you change the name of the file or change the path of this file WordPress will not recognize this file as the template.

So keep in mind that keep this file in the WordPress theme hierarchy.

After you create Single.php file just put index.php file code inside of it.

So we will put that first.

In the previous article, we had created this index.php file.

So here we just put all the code from the index.php file and paste it inside of single.php file.

Only the difference has we created a simple div with post-class which creates single border outside of the post.

In the .col-sm-8 class you will see this code

and then create a style for it.

In above code, we also wrap the sidebar and apply the border and padding to the sidebar also.

If you run your project nothing will change.

Because you did not change anything. To see changes just change or remove something from single.php file.

You will see the result when you on the home page nothing will change and if you go to the single post your previous changes will affect the single post type.

That’s all for this article see you in the next one.

Thank You.