How to create custom post type template files in wordpress

Any wordpress theme comes with a single post, page and archive template. None of these templates may be suitable for you if are creating your own custom post for event, products, etc. In such cases we need to create our own templates There are 2 ways to create custom post type template files in wordpress Method 1: Create custom post type template files within your Child Theme folder Suppose your custom post type is event. You would create below files in your child theme directory. single-event.php archive-event.php Once the above files are created they will be automatically picked for your events single post and archive posts. So whatever your custom post type is, the template file names should be as named as below single-{post-type}.php archive-{post-type}.php Refer Wordpress Theme Handbook Advantages: It is very easy to create and modify your custom post type template files Disadvantages: The template files are not within your plugin. So if you want to install the plugin on some different website you need to remember to get the template files from the theme...
Read More