This is a fairly basic integration to get AI Engine to load the content of ACF custom filed(s) in embeddings sync, context, data set builders and anywhere else it takes the content of a post.
It may not be perfect (I'm sure someone will pick up a way it can be done differently) but this works, including for post-types that don't have the custom field (so it ignores it and uses the content as usual).
function add_acf_mwai( $content, $postId ) {
$custom_filed_1 = get_field( 'your_custom_filed_ID', $postId ); // Get the value of the a ACF custom filed - replace 'your_custom_filed_ID' with the name of the field you wish to use
if ( $custom_filed_1) {
$content .= $your_custom_filed_ID; // Append the value of the 'your_custom_filed_ID' to the post content
}
return $content;
}```
This version should work if you need multiple ACF fields to be appended:
```add_filter( 'mwai_pre_post_content', 'add_acf_fields', 10, 2 );
function add_acf_fields( $content, $postId ) {
$field_1 = get_field( 'ACF_Field_1', $postId );
$field_2 = get_field( 'ACF_Field_2', $postId );
if ( $field_1 ) {
$content .= '<p>' . $field_1 . '</p>'; // Append the value of ACF_Field_1 to the post content
}
if ( $field_2 ) {
$content .= '<p>' . $field_2 . '</p>'; // Append the value of ACF_Field_2 to the post content
}
return $content;
}```