Using Template Parts in Page Templates

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

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

//Declare Variables
$current_user_id = wp_get_current_user()->ID;
$allowedUsers = get_field('website_client');

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

//Content Start
get_header(); 

if (in_array($current_user_id, $allowedUsers, true) || current_user_can('administrator') )
{ //User Has Access
    get_template_part( 'template-parts/section' , //Template Part Location
                       'client-portal' , //Template Part Name
                       array (
                        'pTitle' => $pTitle,
                        'pContent' => $pContent,
                        'fImage' => $fImage,
                        'featuredimageURL' => $featuredimageURL,
                       )
                    );
}
else { //Users Has No Access ?>
<?php get_template_part( 'template-parts/section' ,'no-access' ); 
}
get_footer();

Folder Structure is shown below

[instagram-feed feed=1]
© 2024 BenaDigital Limited | All Rights Reserved
magnifiercrosschevron-down