Create Single Post Template for CPT

First, you need to open a code editor e.g VS Code and paste the following code inside it:

 * Template Name: My Single Post Template Name
 * Template Description: Enter Template Description Here

You can save this file as single-{post-type-slug}.php.

Upload this file using FTP to your WordPress Child Theme Folder. Avoid adding the template file to your parent theme as this will be overwritten when the theme is updated.

Here is an example below for the Astra Child Theme.

 * Template Name: Website Client Template
 * Template Description:The template for displaying all portfolio posts
 * @package Astra

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

$pTitle = get_the_title( $post_id );
$pContent = get_the_content( $post_id );
$featuredimageURL = wp_get_attachment_url( get_post_thumbnail_id($post->ID));


<h1>Welcome to your Client Portal : <?php echo $pTitle?></h1>
if ($fImage) { ?>
    <img src="<?php echo $featuredimageURL ?>" alt="<?php echo $pTitle?>" width="300px"> <?php
} ?>

<p><?php echo $pContent?></p>

<?php get_footer();
[instagram-feed feed=1]
© 2024 BenaDigital Limited | All Rights Reserved