function filter_shorten_linktext($linkstring, $link, $characters = 25) { $characters = $characters; preg_match('/<a.*?>(.*?)<\\/a>/is', $linkstring, $matches); $displayedTitle = $matches[1]; $newTitle = shorten_with_ellipsis($displayedTitle, $characters); return str_replace('>' . $displayedTitle . '<', '>' . $newTitle . '<', $linkstring); }
// WP_Query arguments $args = array('post_parent' => $id, 'post_type' => array('page'), 'posts_per_page' => -1); // The Query $grid = new WP_Query($args); // The Loop if ($grid->have_posts()) { while ($grid->have_posts()) { $grid->the_post(); if (have_rows('g_grantees')) { while (have_rows('g_grantees')) { the_row(); $grantee = get_sub_field('g_grantee'); } } $title = get_the_title(); $title = shorten_with_ellipsis($title, 70); $type_field = get_field_object('g_type'); $type = $type_field['choices'][get_field('g_type')]; $type_data = get_field('g_type'); $area_data = get_field('g_research_area'); $year_data = get_field('g_year'); ?> <a class="grid__item <?php echo $type_data . ' ' . implode(' ', $area_data) . ' ' . $year_data; ?> " data-year="<?php echo $year_data; ?> " data-type="<?php echo $type_data;