Support

Account

Home Forums General Issues Pull in post_content from post object subfield

Helping

Pull in post_content from post object subfield

  • I want to get the post_content from my post object sub field and just simply display the content. Print_r is pulling in the right value, but I can’t get it to echo on the front end. I’ve tried filters, ->post_content, maybe I’m just doing it wrong? I’m still new to ACF.

    
      <?php   
      $d = get_sub_field('day');
    	
    	$top = get_sub_field('topic');
    	$ctxt = get_sub_field('context');
      $wtemp =get_sub_field('writing_template');
    
    	$ctnt = get_sub_field('content');
    	$i = get_sub_field('image');
    	?>
    
    	<h1> <?php echo($d) ?> </h1><br>
    
              <?php if( get_sub_field('context') ) {  ?>
              <p><?php echo($ctxt) ?></p>
              <?php } ?>
    
              <?php if( get_sub_field('writing_template') ) {  ?>
              <p><?php echo($wtemp); ?></p>
              <?php } ?>
    
              <?php if( get_sub_field('topic') ) {  ?>
              <p><strong>Topic:</strong><?php echo($top) ?></p>
              <?php } ?>
     
              <?php if( get_sub_field('content') ) {  ?>
              <p><strong>Content:</strong><?php echo($ctnt) ?></p>
              <?php } ?>
    
              <?php if( get_sub_field('image') ) {  ?>
              <p><strong>Image:</strong> <a>"><?php echo($i) ?></a></p>
              <?php } ?>
    
    

    print_r prints this, I literally just want to display exactly what is in the post_content in a p tag.

    Array ( [blog_ad_template_type] => WP_Post Object ( [ID] => 4186 [post_author] => 1 [post_date] => 2021-07-26 04:05:49 [post_date_gmt] => 2021-07-26 04:05:49 [post_content] => Write a social media ad for [wpbb post:terms_list taxonomy=’brand’ html_list=’no’ display=’name’ linked=’no’] for a blog post using the above blurb. ** [post_title] => Blog Ad Template 1 [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => blog-ad-template-1 [to_ping] => [pinged] => [post_modified] => 2021-07-26 04:29:00 [post_modified_gmt] => 2021-07-26 04:29:00 [post_content_filtered] => [post_parent] => 0 [guid] => https://social.hgcreative.co/?post_type=content_template&p=4186 [menu_order] => 0 [post_type] => content_template [post_mime_type] => [comment_count] => 0 [filter] => raw ) [case_study_template_type] => [quote_template_type] => [resource_template_type] => [review_template_type] => [services_template_type] => [story_template_type] => [tip_template_type] => )

  • 
    $post_object = get_field('post_object_field');
    echo $post_object->post_content;
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.