حقل علاقة ACF في discourse_publish_format_html

بالنسبة لأي شخص يرغب في توسيع حقل علاقة ACF، إليك ما نجح أخيرًا عندما كان نوع المحتوى المخصص (CPT) الذي أرسله إلى Discourse يسمى memes، ويشمل حقل علاقة (ككائن) يسمى meme_person يربط بنوع محتوى مخصص آخر يسمى people

function rs_custom_publish_format_html( $output, $post_id ) {

	$post = get_post( $post_id );
	$type = get_post_type($post_id);
	
	// إذا كانت الصورة المميزة موجودة، استخدمها
	if ( has_post_thumbnail( $post_id ) ) {
		$image = "{thumbnail}<br><br>";
	} else {
		$image = "";
	}

    // إذا كان المنشور من نوع "memes"، احصل على معلومات الحقل المخصص
    if ( 'memes' === $post->post_type) {
    	$comment = get_post_meta($post->ID, 'comment', true);
		$peopleout = ' ';

		$persons = get_post_meta($post->ID, 'meme_person', true);
		if( $persons ):
			foreach( $persons as $person ):
		        $title = get_the_title($person);
				$peopleout .= $title . ' ' ;
			endforeach;
		endif; ?>

        <?php ob_start(); ?>
  
        <small>نُشر في الأصل على: {blogurl}</small><br><br>
        <?php echo $image ?>
        <?php echo $comment ?><br>
        <?php echo $peopleout ?>

        {excerpt}
	  
        <?php 
        $output = ob_get_clean();
        
        return $output;
    }
  
      
    // وإلا، أعد النتيجة
    ob_start();
    the_permalink( $post_id );
	$output = ob_get_clean();
	return $output;
    
}
add_filter( 'discourse_publish_format_html', 'rs_custom_publish_format_html', 10, 2  );