How to make a template for custom post type in wordpress

the custom single post templates structure is same as a post-default template or single.php file, If you find some design change on some case of displaying custom post then you can make a single post display page for the custom post type and we will learn custom post template development step by step

for that, you have to learn how to declare a custom post type in WordPress

now suppose your custom post type id is custom_slider

Now the first step is

create a PHP file by the name single-.php and in this case, the page name will be single-custom_slider.php

and the rest of the step is similar to developing a single.php file

Single custom post

Single custom post

Step 2.

Take an HTML design to display the post and copy the HTML and paste on the single.php file

Step 3.

Now place the header, footer, and sidebar of your theme by using the code  and 

Step 5.

Now fetch all content of the post to be displayed. use the code  and the comment template for the page bu using the code 

Step 6.

now get the title, content and featured image by using the code  and <?php Echo Wp Get Attachment Url( Get Post Thumbnail Id($post >ID)); ?>

Now the full code for making a single.php file inside your theme folder


<?php Echo Wp Get Attachment Url( Get Post Thumbnail Id($post >ID)); ?>

Now we have created a custom single post type template successfully

Thanks for  Reading

Share The Post On -

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.