WordPress.org

Ready to get started?Download WordPress

Forums

Limit chars in the_title(); (2 posts)

  1. vvaz
    Member
    Posted 5 years ago #

    Hello.

    I have a section in my WP 2.7 blog with Recent Posts, but due to design i only want to show the first 50 chars of the_title(); of the posts.

    Is that possible ?
    Thanks in advance!

  2. MichaelH
    Member
    Posted 5 years ago #

    Assuming in a post loop, like

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    then this in the loop would work:
    <?php echo 'shortened title ' .substr($post->post_title,0,50) ; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic