WordPress – create different template for different post type

In this post we will learn how to create different post template for different post type on TwentyTwentyOne theme. Now we want to create a child theme TwentyTwentyOne-Child as like my previous post How to Create a Child Theme?

Another important thinks, we want to know how to create WordPress custom post type, Please visit my previous post. How to Create WordPress Custom Post Types?

I have created custom post type faqs and create new a post to tested different post template for different post type is working or not.


Now please go to your child theme directory and crete new single file with custom post type. Example: single-{POST-TYPE}.php wp-content\themes\twentytwentyone-child\single-faqs.php file because my custom post type is “faqs”.

Now copy all code form original single.php file. wp-content\themes\twentytwentyone\single.php Open single.php via editor and copy all code and past on wp-content\themes\twentytwentyone-child\single-faqs.php

Now copy all code form original content-single.php file wp-content\themes\twentytwentyone\template-parts\content\content-single.php Open content-single.php via editor and copy all code and past on wp-content\themes\twentytwentyone-child\template-parts\content\content-faqs.php

Now call new template parts content like this, just change “content-single” to “content-faqs” on single-faqs.php file get_template_part(‘template-parts/content/content-faqs’);

I added some text on new template for texting FAQs custom template

New custom post type template is working.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Please SHARE this post.

Related Articles