WordPress is one of the most widely used content management systems (CMS). One of the major advantages of WordPress is its flexibility, as the any WordPress user can customize the look and features of any WordPress installation to fit his/her needs and taste. What is even more important is that these modifications could be made either without any prior knowledge to programming using plugins or using very simple codes that the user can just copy and paste.
By default, when you as a user run WordPress and open a new post, WordPress will use the single post standard template, the same one that’s used when you open any other regular blog post. But if we create a new file, we can target certain type (category) of posts exclusively, and create a template that’s only used for these type of posts.
This post is a step by step tutorial on how to create a custom post type template without any plugins.
Step One: Go to your website and log into your WordPress dashboard (www.example.com/wp-admin) and enter your credentials, then enter the dashboard.
Step Two: In your dashboard enter the Appearance menu.
Step Three: In the Appearance menu, go to the “Editor” tab.
Step Four: Open the function.php file at the right hand side of the screen and copy and paste the following code in it.
Of course you should change the function name (codex_custom_init) at the beginning of the code to the name you want (e.g. custom_movies_init) and you should also change the “Book” throughout the code to the name you want (e.g movies, etc.). Congratulations, now you’ve successfully added a custom post type template without any plugin.