Add Admin Side Option Select Post Category Using ACF Taxonomy Field [ Select Post Id in ACF Field ] (Check Box) (Single Product Post Slider Shortcode)



 /* Single Product Post Slider Shortcode */
/* Select Category This Category Post Display From Client Side  */
function single_product_post_slider()
{
global $post;
    ob_start();

if(is_product()){
$post_cat = get_field('select_post_category',$post->ID);
}
else{
$post_cat = get_field('select_specific_post_category',$post->ID);
}

$dataobituary_query = new WP_Query(array(
    'posts_per_page' => 20,
    'category__in' => $post_cat
));

?> 

<div class="single-product-slider">
<div class="owl-carousel post-slider">
<?php 
  // Loop through the obituaries:
while ($dataobituary_query->have_posts()):
$dataobituary_query->the_post();

$img = get_the_post_thumbnail_url($post->ID, 'post-thumbnail');
$product_link = get_permalink($post->ID);
$the_cat = get_the_category($post->ID);
$category_name = $the_cat[0] -> cat_name;
$category_link = get_category_link($the_cat[0] -> cat_ID);
  ?>  
<div class="item">
<div class="post-slider-box">
<?php if(!empty($img)):?>
<div class="post-img">
<a href="<?php echo $product_link; ?>">
<img src="<?php echo $img; ?>" alt="image">
</a>
</div>
<?php endif;?>

<div class="post-content">
<a href="<?php echo $category_link; ?>"><h4><?php echo $category_name; ?></h4></a>
<a href="<?php echo $product_link; ?>"><h2><?php the_title();?></h2></a>
<p><?php the_excerpt();?></p>
</div>
</div>
</div>
  
<?php 
  endwhile;
wp_reset_postdata();
  ?>
</div>
</div>

<?php
    return ob_get_clean();
}
add_shortcode( 'single_product_post_slider' , 'single_product_post_slider' );