Support

Account

Home Forums Add-ons Repeater Field get_post_custom_values

Solved

get_post_custom_values

  • Is it possible to use this function with repeater fields to get all the values for a key.

  • No. Repeater fields are not stored in a way that will let you use this function.

    Without more information I can’t really give you a solution. What are you trying to do?

  • Hello John

    Lets move away from sub & repeater fields.

    How about using basic text or url fields with the same key.

    With WP fields, i could use 1 custom field to add 5 different values

    get_post_meta( get_the_ID(), 'logos', true );

    And then this to get all the values

    $key = get_post_custom_values( 'logos' );

    How do i do this with ACF text or URL fields?

  • You cannot. ACF stores each field with a different meta key, you cannot have multiple fields with the same name. ACF does not use the ability to store multiple values with the same meta key. If you do this as each field is saved the new value will replace the old value.

  • Yes, i worked that out so i had to use a different key for each. Thanks.

    Here’s the code i used :

    
    $logo_1 = get_post_meta( get_the_ID(), 'logo_1', true );
    $logo_2 = get_post_meta( get_the_ID(), 'logo_2', true );
    $logo_3 = get_post_meta( get_the_ID(), 'logo_3', true );
    $logo_4 = get_post_meta( get_the_ID(), 'logo_4', true );
    $logo_5 = get_post_meta( get_the_ID(), 'logo_5', true );
    
    $key = [ $logo_1, $logo_2, $logo_3, $logo_4, $logo_5 ];
    
Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘get_post_custom_values’ is closed to new replies.