Front page


Issues with insertion of ACF fields sourced from other posts into this page
1 DOCUMENTING THE ISSUE: This page highlights the desired workflow and the cases in which ACF fields containing shortcodes do not process the proper ACF field values.
THE SEARCH FOR A SOLUTION: Identification of two post grid plugins, where a solution to the processing issue might be found.

Objective: The objective is to source select ACF fields including texts, images etc. from other posts such as Articles (the source posts) and to insert them into this Front page (the destination page), in order to tease viewers to go and read the full article.
Problem: The problem is that in most cases SHORTCODES contained within ACF custom fields in the post/Articles are NOT executed remotely. They get mixed up when they reach this Front page and process values from the equivalent custom fields present here.
Workflow: The ‘featured’ article ACF field is targeted using the following shortcode:
 [ featured id='123' my_field='featured'] 

(See more details below). It allows to select the specific post and the specific custom field from that post. The ‘featured’ field is then inserted into the Front page. The field itself contains several references to other ACF fields within the source post (Images, texts, links etc.)


The issues arise when the ACF content is called from the fields in the Front page, instead of content from the articles.





2 Inserting the fields from remote posts: The ACF fields below are inserted using the “featured” shortcode which allows to target a post by id and field name.

[ featured id='35400' my_field='featured']

For reference, this custom code provided by the Beaver Builder support team is located in the functions.php of the child theme.).

//  Use  filling the '' with the correct values for you
function gg_get_field($attr){
    $args = shortcode_atts( array(     
            'id' => '1',
            'my_field' => 'featured'
        ), $attr );
 
    return get_field($args['my_field'], $args['id']);
}
add_shortcode( 'featured' , 'gg_get_field' );

There are obviously other methods such as the “Insert page” plugin (no field selection) or ACF’s field display methods (that require developer coding skills which we do not have).



3 To help demonstrate the issue, the text and image ACF field values contained in this Front page’s “featured” field are inserted here before the article inserts:

Source= Front page   id= 36491

The ACF content and values for this page’s “featured” are purposely highlighted to demonstrate how they may show up by error in the tests. They should NOT show up in the Article inserts below. The issues arise only when the source posts’ ACF fields contain shortcodes. Instead of picking up values from the Article, they pick up the content from the Front page fields.


4 Article1 | id= 35400:   The field “featured” contains both Htmland Shortcodes,

Article2 | id= 35406:   The field “featured” contains both Htmland Shortcodes,



5 Conclusion: The shortcodes are correctly identified inside the fields of their source posts, but they end up processing the values from THIS destination page and its custom fields, NOT the ones from the source posts.

Exceptions! There has to be a solution to this issue! Grid based lay out solutions such as Content Views or Beaver Builder “insert Posts” handle multiple posts in bulk and seem to perform the remote shortcode execution and rendering properly. See the expected result in this page /grid-based-acf-post-inserts. The grid solutions manage to pre-process the shortcodes in the source posts. The challenge is to identify how to make the solution consistent ad pervasive across all types of inserts.

Front page