# שדה ACF Relationship ב-discourse\_publish\_format\_html

**URL:** <https://meta.discourse.org/t/acf-relationship-field-in-discourse-publish-format-html/186961>\
**Category:** WordPress\
**Created:** [15 באפריל,‏ 2021,‏ 1:42pm UTC](https://meta.discourse.org/t/acf-relationship-field-in-discourse-publish-format-html/186961 "2021-04-15T13:42:46Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![RichardC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richardc/32/216860_2.png) [@RichardC](https://meta.discourse.org/u/RichardC)\
**Post date:** [16 באפריל,‏ 2021,‏ 7:36pm UTC](https://meta.discourse.org/t/acf-relationship-field-in-discourse-publish-format-html/186961/6 "2021-04-16T19:36:46Z")

</div>

For anyone who wants to expand an ACF relationship field, here’s what finally worked when the CPT I’m sending to Discourse is called `memes` which includes a relationship field (as object) called `meme_person` which links to another CPT called `people`

```plaintext
function rs_custom_publish_format_html( $output, $post_id ) {

	$post = get_post( $post_id );
	$type = get_post_type($post_id);
	
	// if featured image is present, use it
	if ( has_post_thumbnail( $post_id ) ) {
		$image = "{thumbnail}<br><br>";
	} else {
		$image = "";
	}

    // if post is a meme, get the custom field information
    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>Originally published at: {blogurl}</small><br><br>
        <?php echo $image ?>
        <?php echo $comment ?><br>
        <?php echo $peopleout ?>

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

```

---

_[View the full topic](https://meta.discourse.org/t/acf-relationship-field-in-discourse-publish-format-html/186961)._
