• I am trying to add in a “Read More…” link on an excerpt and also limit the length of the excerpt in my functions file to minimize code in my template. For some reason, it’s not limiting the length or adding the “Read More…” link. Am I doing something wrong that I’m not catching?

    This is the code block that I got in my functions.php file.

    /* =================================================================
    Excerpt stuff
    ================================================================= */
    function junavalove_excerpt_length() {
        return 20;
    }
    add_filter( 'excerpt_length', 'junavalove_excerpt_length' );
    
    function junavalove_excerpt_more() {
    	return sprintf( '<a href="%1$s">%2$s</a>', get_permalink( get_the_ID() ), __( 'Read More...') );
    }
    add_filter( 'excerpt_more', 'junavalove_excerpt_more' );

    This is what I got on my index.php template.

    if ( has_excerpt() ) {
    	the_excerpt();
    } else {
    	the_content('Read more...');

Viewing 2 replies - 1 through 2 (of 2 total)
  • this does not get applied in case you are writing your excerpts by hand – only for automatically generated ones.

    Thread Starter laling

    (@laling)

    Is there a way to apply them to manual excerpts?

    I’d like to make use of the excerpts feature in a theme that I’m scrapping up.

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