Support

Account

Forum Replies Created

  • I solved my problem by adding the following line in the variable declaration block of the duplicate post function.

    
    $flexible_content = get_field('YOUR_FLEXIBLE_CONTENT_FIELD', $post_id, false);
    

    And then the following lines in the if ($post) condition block.

    
    if ($flexible_content) {
        update_field('YOUR_FLEXIBLE_CONTENT_FIELD', $flexible_content, $new_post_id);
    }
    
  • In the meanwhile, I will try to dynamically populate the fields choices array and see if that works.

    While this didn’t solve my original problem of the choices/pages not showing up in a ‘Relationship’ type field, the alternative approach described above worked just fine for what I was trying to achieve:

    
        acf_render_field_setting( $field, array(
    		'label'			=> __('Hide on Pages', 'jdmn'),
    		'instructions'	=> __('Hide this field on the following pages.', 'jdmn'),
    		'name'			=> 'hide_on_pages',
    		'type'          => 'select',
            'choices'       => (function(){
                $array = array();
                $pages = get_pages();
                foreach( $pages as $page ) {
                    $array[$page->ID] = $page->post_title;
                }
                return $array;
            })(),
            'default_value' => null,
            'allow_null'    => 1,
            'multiple'      => 1,
            'ui'            => 1,
    	), true);  
    
  • Thanks for clearing that up. In the meanwhile, I managed to achieve the visual result I was aiming for using the CSS column-count and column-span properties.

  • I was facing the same issue and came up with this more robust CSS-based solution which targets the relevant CSS class and will work across possible translations of the “No image selected”-string.

    
    .hide-if-value :not(a) {
        font-size: 0px;
        color: transparent;
    }
    

    This selector can optionally be prepended with the .acf-image-uploader or .acf-file-uploader selector in case you want to target these fields specifically.

Viewing 4 posts - 1 through 4 (of 4 total)