Forums

Shorten Length of Title for a List of Posts (3 posts)

  1. seaphire
    Member
    Posted 2 years ago #

    I am trying to shorten the title of the posts displayed given in a list when calling the following function inside of WordPress:

    <ul>
     <?php
     global $post;
     $tmp_post = $post;
     $myposts = get_posts('numberposts=5&offset=1&category=12');
     foreach($myposts as $post) :
       setup_postdata($post);
     ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
     <?php $post = $tmp_post; ?>
     </ul>

    Basically, if you go to Mashable.com, scroll down the page, and the grey box that has technology, entertainment, web dev, etc... it displays the top posts with ...'s after the titles. How are they able to shorten the title?

  2. seaphire
    Member
    Posted 2 years ago #

    I got it... and if anyone else ever stumbles upon this, here's how:

    http://www.knowtebook.com/wordpress-shorten-the-title-of-posts-or-everything-else-you-want-872.htm

  3. doc4
    Member
    Posted 1 year ago #

    If anyone is needing an alternative method this is article shows five ways to shorten the post title.

    http://www.doc4design.com/articles/wordpress-5ways-shorten-titles/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.