Support

Account

Forum Replies Created

  • Hi Guys!

    I was able to solve this. If you’re using PHP 5.5+ then you can do it like this:

    
    // get flexible content field object
    $layout = get_field_object( 'flexible_content_field' );
    
    // find current layout
    $key    = array_search( get_row_layout(), array_column( $layout['layouts'], 'name' ) );
    
    // output label
    echo $layout['layouts'][ $key ]['label'];
    

    Hope this helps!

  • Why is ACF using the plugin version for the select2 script version? The big issue here is select2 is being registered using the plugin version and not the select2 script version. You should always use the script version when you enqueue – that way if another plugin is using the script, WP can compare versions and use the newest one.

    https://developer.wordpress.org/reference/functions/wp_enqueue_script/

    This needs to be changed to avoid compatibility issues with plugins in the future.

  • I was able to solve this by finding the total amount of rows in your field by using get_field_object.

    In your code, after if( have_rows('cm_content') ): try this:

    $field_object = get_field_object('cm_content');
    $total_rows = count($field_object['value']);
    

    Then you can test for it with an if statement:

    if($counter == $total_rows ){
    // this is the last one!
    }
    

    Cheers,

    Andre

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