GeoDirectory does not print a breadcrumb of its own. The breadcrumb you see on a listing page comes from your theme or from an SEO plugin such as Yoast SEO or Rank Math, and the last item is the listing title. A long title makes a long breadcrumb, so there are two ways to shorten it: cut the text with CSS, or shorten the title only inside the breadcrumb with a small filter.
Shorten it with CSS
CSS can cut the last item to a fixed width and add an ellipsis. The listing title on the page stays as it is. Add this at Appearance > Customize > Additional CSS and change the class to match your breadcrumb. .breadcrumb_last is the class Yoast SEO gives the last item.
.breadcrumb_last {
display: inline-block;
max-width: 250px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: bottom;
}
If your theme prints the breadcrumb, use your browser’s inspect tool on the last item to find its class.
Shorten the breadcrumb text with Yoast SEO
GeoDirectory already hooks into the Yoast breadcrumb to add the listing category. You can use the same wpseo_breadcrumb_links filter to trim the listing title to a few words on listing pages only. Add the snippet with the Code Snippets plugin or your child theme’s functions.php.
add_filter( 'wpseo_breadcrumb_links', 'my_gd_short_breadcrumb', 20 );
function my_gd_short_breadcrumb( $crumbs ) {
if ( ! function_exists( 'geodir_is_page' ) || ! geodir_is_page( 'detail' ) || empty( $crumbs ) ) {
return $crumbs;
}
$keys = array_keys( $crumbs );
$last = end( $keys );
if ( ! empty( $crumbs[ $last ]['text'] ) ) {
$crumbs[ $last ]['text'] = wp_trim_words( $crumbs[ $last ]['text'], 4, '...' );
}
return $crumbs;
}
Change 4 to the number of words you want to keep.
Shorten the breadcrumb text with Rank Math
Rank Math stores the text of each item in the first position of the item array, so the snippet looks like this:
add_filter( 'rank_math/frontend/breadcrumb/items', 'my_gd_short_rank_math_breadcrumb', 30 );
function my_gd_short_rank_math_breadcrumb( $crumbs ) {
if ( ! function_exists( 'geodir_is_page' ) || ! geodir_is_page( 'detail' ) || empty( $crumbs ) ) {
return $crumbs;
}
$keys = array_keys( $crumbs );
$last = end( $keys );
if ( isset( $crumbs[ $last ][0] ) ) {
$crumbs[ $last ][0] = wp_trim_words( $crumbs[ $last ][0], 4, '...' );
}
return $crumbs;
}
If the breadcrumb comes from your theme, check the theme’s documentation for a breadcrumb filter. The same idea works there: check geodir_is_page( 'detail' ) and trim the last item.