Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 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_excerpt();
      }
    }

    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); ?>

    Hi! Try adding this snippet of code to your theme’s style.css file:

    a img.entry-featured-image {
        display: block;
        margin-left: auto;
        margin-right: auto;
    }

    I don’t think it serves a purpose at all, because the elseif block of code will never be executed.

    The reason is that is_singular returns TRUE if any of the following returns TRUE: is_single(), is_page()or is_attachment(). Therefore, the code will enter the if block even if !is_page() (in other words, the flow of control will enter the if block even if the elseif test case returns TRUE). Since it enters the if block, the flow of execution will then bypass the elseif test.

    My guess is that whoever wrote the function meant to write the if test as if ( is_single () ) { } and not as if ( is_singular() ) { }

Viewing 3 replies - 1 through 3 (of 3 total)