I've created a custom posts called Projects and created a Projects template inside of archive-projects.php. I've also created a single-projects.php to display individual project. However, this became a problem when I had to use an ACF on the Projects template. I want to display a featured project on the Project page and also list out few of the posts I've created for projects on the same page. Below is my code to get featured project image.
<?php echo get_field('featured_project'); ?>
<?php
$featured_project = get_field('featured_project');
if ($featured_project):
$project = $featured_project;
setup_postdata( $project );
if ( has_post_thumbnail($featured_project->ID) ) { // check if the post has a Post Thumbnail assigned to it.
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id($featured_project->ID), 'large' );
$featured_image = $featured_image[0];
}
?>
I've read few articles and similar questions on Stackoverflow but haven't found an answer yet. Has anyone been successful figuring this out?