Check out the WordPress Dictionary Plugin!

Tutorial: How to display short blog title in WordPress


Posted on 24th December, by Anne in Development. 13 Comments

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”

  1. ForexEffonse says:

    what an informative posts, I will bookmark this site to digg. Regards, Reader.

  2. EliasTiez says:

    This brings me to an idea:…

  3. LnddMiles says:

    Great post! I’ll subscribe right now wth my feedreader software!

  4. andy says:

    try to change it to work with 3.0, brgs

  5. andy says:

    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

  6. andy says:

    another way

    here must be the php opener

    wp_title(”, true, ”, true);

    and here you must close the php code

  7. roger says:

    have any idea how to use short tile for wp -ecommerce
    currently i am using

    Thanks in Advance

  8. roger says:

    php echo wpsc_the_product_title();

    sorry for multiply post

  9. roger says:

    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;
    }

  10. Can says:

    thank you so much. im just looking for

Leave a Reply