Support

Account

Home Forums Add-ons Flexible Content Field Load flexible content field from setting page

Unread

Load flexible content field from setting page

  • Hi Guys,

    I have created a settings page, in it I have a flexible content field with 2 sub fields.
    On a Post I have another flexible content field, identical to my settings page, I am trying to take the values entered on the setting page and have them populate on the post as “default values”.

    Here is the code I am trying, but its not working, it keeps creating empty fields on my post and messes up the field group also!

    function acf_load_deliverables( $field ) {
    	$field = array();
    		
    		if( have_rows('deliverables', 'option' )){
    			
    			// loop through the rows of data
    			while ( have_rows('deliverables', 'option') ) : the_row();
    			
    				if( get_row_layout() == "new_deliverable" ){
    					
    					$field = array(
    						array(
    						  'acf_fc_layout' => 'development_deliverables',
    						  'deliverables' => get_sub_field('deliverables'),
    						  'days' => get_sub_field('days')
    						));
    				}
    				else {
    					echo "no rows";
    					echo "<br />";
    				}
    			endwhile;
    		}
    		else
    			echo "no rows"; 
        
        return $field;
    }
    add_filter('acf/load_field/key=field_5d0b74c37ad29', 'acf_load_deliverables');

    Does anyone have an example of this working I could reference?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.