Home Forums Add-ons Repeater Field Limit Output Characters on Sub-Field


Limit Output Characters on Sub-Field

  • I need assistance limiting characters on a the_sub_field on output. Any help would be greatly appreciated.

  • use get_sub_field and substr

    // limit to 10 chars
    $value = substr(get_sub_field('field_name'), 0, 10);
    echo $value;

    or you can use wp_trim_words() to limit to a number of words

    // limit to 10 words
    $value = wp_trim_words(get_sub_field('field_name'), 10);
    echo $value;
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Limit Output Characters on Sub-Field’ is closed to new replies.