Truncate function to limit Post title to specific number
- Edi
- Site Admin
- Posts: 3085
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 71 times
- Been thanked: 105 times
- Contact:
You can use the PHP function substr:
https://www.php.net/manual/de/function.substr.php
For example add the following to the templates home.php and page.php (in the directory bl-themes/blekathon/php):
Then replace
with
https://www.php.net/manual/de/function.substr.php
For example add the following to the templates home.php and page.php (in the directory bl-themes/blekathon/php):
Code: Select all
<?php
$title = $page->title();
$title = substr($title, 0, 10);
?>
Code: Select all
<?php echo $page->title(); ?>Code: Select all
<?php echo $title; ?>aufbruch1900.ch, Plattform zu Kunst und Kultur um 1900
- Edi
- Site Admin
- Posts: 3085
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 71 times
- Been thanked: 105 times
- Contact:
Code: Select all
<?php
$title = $page->title();
if (strlen($title) > 10) {
$title = substr($title, 0, 10).'...';
} }
?>
This question is not Bludit related.Also, instead of character count I want to truncate/count word
But it can be done with PHP:
https://www.php.net/manual/de/function. ... -count.php
aufbruch1900.ch, Plattform zu Kunst und Kultur um 1900

