Do you want to create a custom post types single page or create a single template in WordPress without using any plugin or page builder?
By default, custom post types in WordPress would use your own or premium theme’s single.php template. Also, you can create your own custom single page for any custom post type..
So, in this article, we will show you how to create custom post types single-page templates in WordPress.
What is the Custom Post Type Single Page in WordPress?
We can say, a custom post type single page is where users can view a single post item filed under a particular custom post type.
You can purchase your hosting from Cloudsurph.com, Cloudsurph hosting is a reliable hosting option for business and personal projects. We offer insight and help on system configuration issues and code errors or bugs.
Normally, WordPress comes with two commonly used post types, known as Posts and Pages. And many WordPress plugins may also create their own custom post types.
So, you can also create custom post types and use them for different types of content for your WordPress website. Also please check the custom post type Archive page.
After creating your custom post type like the previous article, you will use it inside the WordPress admin panel.
IF you want then buy a good, reliable, secure web hosting service from here: click here
Although, your WordPress theme is responsible for displaying all of your content.
Now, if your theme does not have any template for a particular post type, then WordPress will use the default single template like single.php to display any post type item for the single page.
So, if you want to change how your custom post types single page is displayed, then you need to do so by creating a custom template.
It is said that, let’s take a look at how to create a custom post types single page in WordPress.
Create Custom Post Types Single Pages and Template in WordPress
You can create a custom template for your custom post types single page for allows you to customize it to fit your needs with custom meta fields values.
In this case, you can remove the sidebar, change the layout of the page, and provide more context to make the single page more looking good and arrange it your own way with custom meta field values.
Following are a few examples of custom post types single pages with their own custom templates.
We have given below a custom post type single template code, you need to just copy and paste your own theme file.
Create new template for show single post like this
single-{custom post type name}.php or single-products.php
Now, go to your theme folder and create a file like single-products.php, because we already created a custom product post type and created an archive template.
So now copy and paste the below code into your file:
<?php /** * BR Theme - Single-Product **/ get_header(); ?> <section id="wrapper" class="wrapper section products-section custom-product-single-page rony no-wider-page has-sidebar right-sidebar"> <div class="container"> <div class="row"> <div class="col-lg-8"> <div class="product-single-item"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $ad_image= get_post_meta($post->ID, 'ad_image', true); ?> <?php //$product_nametwo= get_post_meta($post->ID, 'product_nametwo', true); ?> <div class="product-single-item-info"> <h3><?php echo get_the_title(); ?></h3> <?php if ( has_post_thumbnail() ) : ?> <div class="product-single-item-thumbs"><?php the_post_thumbnail('post-thumbnails', array("class" => "thumbs")); ?></div> <?php endif; ?> <?php the_content();?> <h5>Click For Download File:</h5> <div class="cproduct-info"> <h6> <span style="display:none;"> <?php $terms = get_the_terms( $post->ID, 'cproducts-categories' ); foreach ($terms as $term) { $name = $term->name; $cat_link = get_term_link( $term->slug, 'cproducts-categories' );?> <i class="fa fa-external-link" aria-hidden="true"></i> <a href="<?php echo $cat_link; ?>"><?php echo $name; ?></a> <?php };?> </span> <i class="fa fa-download" aria-hidden="true"></i> <a href="<?php echo $ad_image;?>" target="_blank">Catalog</a> <i class="fa fa-pencil-square-o" aria-hidden="true"></i> <a href="/purchase-inquiry" target="_blank">Purchase Inquiry</a> </h6> </div> </div> <?php endwhile; endif; ?> </div> </div> <div class="col-lg-4"> <?php dynamic_sidebar( 'sidebar' ); ?> </div> </div> </div> </section> <?php get_footer(); ?>
Finally you go to your Products page and let see your all products item show there, that’s it.
That’s it. If you enjoyed reading this article and have more questions please reach out to our support team via live chat or email and we would be glad to help you. we provide server hosting for all types of need and we can even get your server up and running with the service of your choice.