skip to Main Content

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


  1. work with this code:

    echo mb_substr(get_the_title(), 0, 30);
    
    Login or Signup to reply.
  2. I don’t know how to remove the long title below the thumbnail

    There will be <h2><?php the_title(); ?></h2> in your any one template. Remove that and title will be removed.

    change the size of the title above.

    This will be resolved with some lines of CSS.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search