Support

Account

Home Forums General Issues Shorten the text output of a Text Field

Solving

Shorten the text output of a Text Field

  • I would like to shorten the output of a text field by limiting the number of characters and adding a “…” at the end of the result.

    I found a code to shorten the Title of the post, which comes in handy but this time I would like to shorten a text custom field called “event_location”.

    This was the code I found:

    <?php
    echo substr(get_the_title(), 0,85).”…”;
    ?>

    Is there a way to achieve the same results for the text field?

  • 
    echo substr(get_field('event_location'), 0,85).'…';
    
  • Thanks for your answer. What would be the code to get the field if it is inside a group?

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

You must be logged in to reply to this topic.