Tutorial: How to display short blog title in WordPress
As was recently pointed out to me by Andy in the comments, this post was quite out of date. I was fairly new to WordPress and had found a hacked way to modify the core of WordPress to return a short version of wp_title(); — but this is a method far from necessary and will always get removed when you update WordPress.
I opted to delete the out-of-date method, so that you only get the stuff that makes sense!
There is a simple script you can use to implement a short blog title without modifying the base WordPress code. Open up your functions.php file within your theme and add the following:
[php]function short_title() {
$title = get_the_title();
$count = strlen($title);
if ($count >= 25) {
$title = substr($title, 0, 25);
$title .= ‘…’;
}
echo $title;
}[/php]
You can now reference short_title(); anywhere within the loop and call your short title. You can adjust how long your title is by changing the number “25″ to however many characters you want.
13 Responses to “Tutorial: How to display short blog title in WordPress”
Leave a Reply
what an informative posts, I will bookmark this site to digg. Regards, Reader.
This brings me to an idea:…
Great post! I’ll subscribe right now wth my feedreader software!
try to change it to work with 3.0, brgs
hmmm, this post script can’t show the call code
)))))))))))))))
ok, I try this way – all from bottom must be in one sequence, in one line
start_code__end_code
end delete start_code_ and _end_code
another way
here must be the php opener
wp_title(”, true, ”, true);
and here you must close the php code
have any idea how to use short tile for wp -ecommerce
currently i am using
Thanks in Advance
php echo wpsc_the_product_title();
sorry for multiply post
you mean some thing like this
function short_title() {
$title = wpsc_the_product_title();
$count = strlen($title);
if ($count >= 25) {
$title = substr($title, 0, 25);
$title .= ‘…’;
}
echo $title;
}
thank you so much. im just looking for
what an informative posts, I will bookmark this site to digg. Regards, Reader.
This brings me to an idea:…
Great post! I’ll subscribe right now wth my feedreader software!
try to change it to work with 3.0, brgs
hmmm, this post script can’t show the call code
)))))))))))))))
ok, I try this way – all from bottom must be in one sequence, in one line
start_code__end_code
end delete start_code_ and _end_code
another way
here must be the php opener
wp_title(”, true, ”, true);
and here you must close the php code
have any idea how to use short tile for wp -ecommerce
currently i am using
Thanks in Advance
php echo wpsc_the_product_title();
sorry for multiply post
You should still be able to do this from your functions.php!
All you need to do is substitute
get_the_title()
with
wpsc_the_product_title()
you mean some thing like this
function short_title() {
$title = wpsc_the_product_title();
$count = strlen($title);
if ($count >= 25) {
$title = substr($title, 0, 25);
$title .= ‘…’;
}
echo $title;
}
Yep, that should work! I haven’t tested that code, but it looks right.
thank you so much. im just looking for