Campo Relazione ACF in discourse_publish_format_html

Per chiunque voglia espandere un campo di relazione ACF, ecco cosa ha funzionato alla fine quando il CPT che invio a Discourse si chiama memes e include un campo di relazione (come oggetto) chiamato meme_person che collega a un altro CPT chiamato people

function rs_custom_publish_format_html( $output, $post_id ) {

	$post = get_post( $post_id );
	$type = get_post_type($post_id);
	
	// se è presente un'immagine in evidenza, usala
	if ( has_post_thumbnail( $post_id ) ) {
		$image = "{thumbnail}<br><br>";
	} else {
		$image = "";
	}

    // se il post è un meme, ottieni le informazioni del campo personalizzato
    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>Originariamente pubblicato su: {blogurl}</small><br><br>
        <?php echo $image ?>
        <?php echo $comment ?><br>
        <?php echo $peopleout ?>

        {excerpt}
	  
        <?php 
        $output = ob_get_clean();
        
        return $output;
    }
  
      
    // altrimenti restituisci
    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  );