I want to truncate post titles in my page template.
Here’s the code I’m using which isn’t working:
$titletext = wp_trim_words( get_the_title(), 25, '...' );
$thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
I’ve also tried:
$titletext = customTitle(30);
(having entered the relevant code in functions.php) This has almost worked – it puts the truncated title above the thumbnail, which is fine, except that I don’t know how to remove the long title below the thumbnail or change the size of the title above.
The page is: https://thecraftygardeners.co.uk/project/
I’d appreciate some help – I’m a beginner, but I think I’m nearly there…
2
Answers
work with this code:
There will be
<h2><?php the_title(); ?></h2>
in your any one template. Remove that and title will be removed.This will be resolved with some lines of CSS.