• Resolved jacksonrumi

    (@jacksonrumi)


    I have used this code for read more but it does not work, someone can provide me the correct code

    /*This Code is For Read More Fuction*/
    function excerpt($num) {
    $limit = $num+1;
    $excerpt = explode(‘ ‘, get_the_excerpt(), $limit);
    array_pop($excerpt);
    $excerpt = implode(“,$excerpt).” ID) .” ‘ id='”.readmore.”‘>Read More;
    echo $excerpt;
    }
    function wpse_filter_excerpt_length( $length ) {
    if ( is_front_page() ) {
    return 55; // change this to number of words you want on homepage.
    } else {
    return $length;
    }
    }
    add_filter( ‘excerpt_length’, ‘wpse_filter_excerpt_length, 999 );

Viewing 4 replies - 1 through 4 (of 4 total)
  • what is ‘not working’?
    what is the result of the code?
    what do you want instead?

    what theme are you using?

    Hello jacksonrumi,

    There are some syntax error in the code you’re using, I’ve corrected your code and here is the final code,
    please try this one:

    <?php
    function excerpt($num) {
     $limit = $num + 1;
     $excerpt = explode ( ' ', get_the_excerpt (), $limit );
    
     array_pop ( $excerpt );
    
     $excerpt = implode ( ", ", $excerpt ) . ' <a href="'. get_permalink() .'" id="readmore">Read More</a>';
    
     echo $excerpt;
    }
    function wpse_filter_excerpt_length($length) {
     if (is_front_page ()) {
      return 55; // change this to number of words you want on homepage.
     } else {
      return $length;
     }
    }
    add_filter( 'excerpt_length', 'wpse_filter_excerpt_length', 999 );
    ?>

    Thread Starter jacksonrumi

    (@jacksonrumi)

    Thanks for providing the right code. I checked it working, thanks again.

    Thread Starter jacksonrumi

    (@jacksonrumi)

    Hi cedcommerce
    Again thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Read more code not work’ is closed to new replies.