Support » Theme: Spacious » Post Previews

  • Using the Spacious Theme, is there a way to change the character length of the post preview that appears on the home page and category pages?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi! Try adding this snippet of code to your theme’s functions.php file:

    function short_excerpt($num) {
      $limit = $num+1;
      $excerpt = str_split(get_the_excerpt());
      $length = count($excerpt);
      if ($length>=$num) {
        $excerpt = array_slice( $excerpt, 0, $num);
        $excerpt = implode("",$excerpt)."…";
        echo $excerpt;
      } else {

    The snippet above includes a new function called short_excerpt(). Instead of using <?php the_excerpt() ?> at lines 46-48 of the Spacious content.php file, you can now use the new short_excerpt() function and your desired character limit. For example, if you want to limit your excerpt to 25 characters the code would look like this:

    <?php short_excerpt(25); ?>

    Perfect thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Previews’ is closed to new replies.