• Okay, to clarify – I don’t want the posts content in an excerpt – rather the actual title that shows up in recent posts to be cut down.

    There may be another option available as well – I’m open to any suggestions. The thing is that I can’t reduce the font-size further because it will be too small. So what’s should I do here?

    I’ve tried searching but all I can find is dealing with the posts content.

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php echo wp_trim_words( get_the_title(), 3 ); ?> Change the number 3 in the code to the number of words from your title that you want.

    Thread Starter NovaSev

    (@novasev)

    This is the code I have for recent posts in my footer – it’s not an added widget, just added custom. Where would I place the code you just mentioned? Sorry, I’m crap with PHP still – trying to learn though 🙂

    <?php
       $args = array( 'numberposts' => '7' );
       $recent_posts = wp_get_recent_posts( $args );
       foreach( $recent_posts as $recent ){
    	echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Take a look at '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li> ';
       }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display a posts title as an excerpt?’ is closed to new replies.