This topic has 4 replies, 2 voices, and was last updated 9 years by 5high-photohub.
-
Author
Tagged: post, Thumbnails, excerpts, more text
-
March 31, 2015 at 07:49 #523605high-photohubParticipant
Hi,
I’m using the post excerpts displaying in thumbnails (left small thumb) but the excerpts are really short and look way too small compared to the depth of the thumbnails (see attched).
How can I increase the amount of text shown here?
Many thanks.
Attachments:
You must be logged in to view attached files.March 31, 2015 at 15:22 #52391sharmstrModeratorKleo has its own function for excerpts. Copy the function into your child theme functions.php file and edit as necessary.
COPY CODE\[[^\]]*\]
By default, Kleo will limit the characters to 50 or the words to 20. I’ve changed the characters to 100 above. If you want to increase that, change the ‘100’ in two places to whatever you want. If you want to change it to words, set $chars = false and change $limit = *how many words you want*
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
March 31, 2015 at 22:08 #525285high-photohubParticipantThanks Sharmstr,
I’ve tried it both ways and neither work – in fact they both make the excerpt shorter!? The code I used was this for increasing characters to 100 (as yours above) which produced NO excerpt at all:
COPY CODEfunction kleo_excerpt( $limit = 20, $chars = true ) { $except_initial = strip_tags( get_the_excerpt() ); if ( $chars ) { $excerpt = explode( ' ', $except_initial, '100' ); if ( count( $excerpt ) >= '100' ) { array_pop( $excerpt ); $excerpt = implode( " ", $excerpt ) . '...'; } else { $excerpt = implode( " ", $excerpt ) . ''; } /** TODO */ $excerpt = preg_replace( '<code>\[[^\]]*\]</code>', '', $excerpt ); return '<p>' . $excerpt . '</p>'; } else { $excerpt = $except_initial; return '<p>'. substr( $excerpt, 0, $limit ) . ( strlen( $excerpt ) > $limit ? '...' : '' ) . '</p>'; } }
and this for limiting by words to 50 which made the excerpt even shorter:
COPY CODEfunction kleo_excerpt( $limit = 50, $chars = false ) { $except_initial = strip_tags( get_the_excerpt() ); if ( $chars ) { $excerpt = explode( ' ', $except_initial, '100' ); if ( count( $excerpt ) >= '100' ) { array_pop( $excerpt ); $excerpt = implode( " ", $excerpt ) . '...'; } else { $excerpt = implode( " ", $excerpt ) . ''; } /** TODO */ $excerpt = preg_replace( '<code>\[[^\]]*\]</code>', '', $excerpt ); return '<p>' . $excerpt . '</p>'; } else { $excerpt = $except_initial; return '<p>'. substr( $excerpt, 0, $limit ) . ( strlen( $excerpt ) > $limit ? '...' : '' ) . '</p>'; } }
I’ve obviously copied it incorrectly somehow. Can you check it for me?
(I’ve attached screen shots of both FYI.)
Many thanks,
JAttachments:
You must be logged in to view attached files.March 31, 2015 at 22:43 #52548sharmstrModeratorI think I was smoking something earlier. I just tested this and this seems to be whats works
COPY CODE\[[^\]]*\]
COPY CODE\[[^\]]*\]
Just change the limit.
But keep in mind that it initially gets the standard WP excerpt which is limited to 50 words by default.
If it were me, I’d just do this
COPY CODEfunction kleo_excerpt( $limit = 10, $chars = true ) { return strip_tags( get_the_excerpt() ); }
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
April 1, 2015 at 00:01 #525935high-photohubParticipantThanks for that. I did try your last recommendation with an increase to the default of 50 wors, so like this:
COPY CODEfunction kleo_excerpt( $limit = 50, $chars = false ) { return strip_tags( get_the_excerpt() ); }
and it works great!
Thanks again.
-
AuthorPosts
The forum ‘KLEO’ is closed to new topics and replies.