I am trying to populate the Advanced Custom Fields field by pulling data from a custom post type located in the main blog of a tiered installation.
For a better understanding, I made this simple flow chart.

So, I created a function to pull data from the main blog and show how the radio elements are on the subsidiary site.
The function looks like this and I used this as a reference
function getctas($field) { $field['choices'] = array(); switch_to_blog(1); $args = array( 'post_type' => 'location_icons', 'posts_per_page' => '-1', ); $ctas = new WP_Query( $args ); while ( $ctas->have_posts()) { $ctas->the_post(); $choices = get_field('icon',false); $choices = explode("\n", $choices); foreach( $choices as $choice ): $field['choices'][ $choice ] = '<img src="'.$choice.'"/>'; endforeach; } restore_current_blog(); return $field; } add_filter('acf/load_field/name=call_to_action_icon', 'getctas');
I correctly understood the parameters (options are images), I successfully pulled out the icon field from the main blog and placed the radio and the value as a label.
The problem I am facing is that after the message is saved, when I request it on the child page template, I get the correct images, but the title of the blog post 1 is repeated. Ideal would be:
- Picture
- Blog Title
- Children's Blog Post Desc
And what I get instead is:
- Correct image
- CTP header containing blog image 1
No description
Correct image
- Same name as previous.
- No description
And so on.
If any of you need further clarification to help me solve this problem, I will be happy to explain further.
wordpress advanced-custom-fields
Jaypee
source share