• Hey Guys,

    I have posts that are made up of Advanced Custom Fields data. I would like to post that data to my Facebook Group when the post is published. To handle the posting I am using the plugin NextScript: Social Network Auto Poster.

    The autopost feature works but it does not show any of the ACF data because it is not in the_content. To get around this I have been trying to save the ACF data into the_content by using a filter. I have not successfully been able to achieve this.

    To simplify things I have all my ACF data setup in a template part which I will use get_template_part function to display the ACF fields.

    Currently I have:

    function my_acf_save_post( $post_id ){
    
    	if(get_post_type($post_id) == ''){ 
    
    		$fields = false;
    	 
    		if( isset($_POST['fields']) ){
    			$fields = $_POST['fields'];
    			print_r($fields);
    die();
    			$new_content = '';
    			
    			$new_content .= get_template_part('template-parts/content','main-tip');
    			
    			$my_post = array(
    			'ID'           => $post_id,
    			'post_content' => $new_content
    			);
    			remove_action('save_post', 'my_acf_save_post', 20);
    			wp_update_post( $my_post );
    			add_action('save_post', 'my_acf_save_post', 20);
    		}
    	}
    }
     
    add_action('save_post', 'my_acf_save_post', 20);
  • The topic ‘ACF Social Network Auto Poster’ is closed to new replies.