Truncate function to limit Post title to specific number
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 77 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; ?>
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 77 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
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets