function show_doctor_review_box( $content ) {
// شرط‌ها: فقط در نوشته‌های تکی و اگر فیلد ACF وجود داشته باشد
if ( ! is_single() || ‘post’ !== get_post_type() || ! function_exists(‘get_field’) ) {
return $content;
}

$current_post_id = get_the_ID();
$field_value = get_field(‘reviewed_by_doctor’, $current_post_id);

if ( empty($field_value) ) {
return $content;
}

// تشخیص ID پزشک
$doctor_id = 0;
if ( is_object($field_value) ) {
$doctor_id = $field_value->ID;
} elseif ( is_numeric($field_value) ) {
$doctor_id = $field_value;
} else {
return $content;
}

// دریافت اطلاعات پزشک
$doc_name = get_the_title($doctor_id);
$doc_link = get_permalink($doctor_id);
$doc_img = get_the_post_thumbnail_url($doctor_id, ‘thumbnail’);
if ( ! $doc_img ) $doc_img = ‘https://via.placeholder.com/80’;

// HTML باکس
$html = ‘



تایید علمی توسط

‘ . $doc_name . ‘

این محتوا توسط پزشک یا متخصص بازبینی و تایید علمی شده است.

' . $doc_name . '

توجه: اطلاعات این مقاله صرفاً جهت آگاهی است و جایگزین توصیه پزشک نمی‌باشد.

‘;

return $content . $html;
}
add_filter( ‘the_content’, ‘show_doctor_review_box’, 20 );

Comments are disabled.