Amit

How to limit acf field value in WordPress

If you want to limit the ACF field character output. you can use below code.

1) Make sure to use get_field instead of the_field to get the value.

<?php 
$field = get_field('acf_field_name');
echo substr($field, 0, 200); 
?>

2) I would recommend using the built in WP function wp_trim_words

<?php 
$excerpt = wp_trim_words( get_field('acf_field_name' ), 
$num_words = 50, $more = '...' ); 
?>

Last Update on:March 5th, 2023 at 5:19 pm


Get wordpress posts grouped by years and months
Previous post