แก้โค้ดครับ ตามนี้ครับ
template-parts/recent-posts-2.php
จาก
$the_query = new WP_Query(array(
'post__not_in' => array($postid),
'posts_per_page' => 4,
));
แก้เป็น
$category_detail = get_the_category($postid);
foreach($category_detail as $ci) {
$the_cat_id = $ci->cat_ID;
}
$the_query = new WP_Query(array(
'cat' => $the_cat_id,
'post__not_in' => array($postid),
'posts_per_page' => 4,
));