The GD > Post Content block can cut a listing description down to a word limit or a height and add a read more link. The link opens the full listing, so it is meant for listing cards on archive and search pages. On the listing’s own page the link only points back to the same page.
Shorten the description on listing cards
Add GD > Post Content to your archive item template (GeoDirectory > Settings > General > Pages > Archive item page) and set:
- Word limit: the number of words to show. Tags are stripped.
- Max height: a height in pixels. Longer text fades out at that height.
- Read more link: the link text. Enter
0to hide the link.
The shortcode version looks like this:
[gd_post_content key="post_content" show="value" max_height="120" read_more="Read more..."]
See how to change the length of the text shown for more on listing card text.
Expand the description on the listing page
There is no built-in toggle that expands the text in place on the details page. If you use GD > Post Content with a Max height on your details template, this snippet makes the read more link open the rest of the description on the same page. Add it with the Code Snippets plugin:
add_action( 'wp_footer', function () {
if ( ! function_exists( 'geodir_is_page' ) || ! geodir_is_page( 'single' ) ) {
return;
}
?>
<script>
document.addEventListener( 'click', function ( e ) {
var link = e.target.closest( '.geodir-field-post_content .gd-read-more' );
if ( ! link ) {
return;
}
e.preventDefault();
link.closest( '.geodir-field-post_content' ).style.maxHeight = 'none';
link.remove();
} );
</script>
<?php
} );
All the block settings are listed in GD > Post Content.