Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bluewater2

    (@bluewater2)

    Found the Code with causes the error in the function.php under “Custom Excerpt Length”.

    /*
    **  Custom Excerpt Length
    */
    
    function ashe_excerpt_length( $link ) {
    
    	if ( is_admin() ) {
    		return $link;
    	}
    
    	$link = sprintf( '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
    		esc_url( get_permalink( get_the_ID() ) ),
    		/* translators: %s: Name of current post */ 
    		sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'ashe' ), get_the_title( get_the_ID() ) )
    	);
    
    	return 2000;
    }
    
    add_filter( 'excerpt_length', 'ashe_excerpt_length', 999 );
    
    
    
    function ashe_new_excerpt( $link ) {
    
    	if ( is_admin() ) {
    		return $link;
    	}
    
    	$link = sprintf( '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
    		esc_url( get_permalink( get_the_ID() ) ),
    		sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'ashe' ), get_the_title( get_the_ID() ) )
    	);
    
    	return '...';
    }
    add_filter( 'excerpt_more', 'ashe_new_excerpt' );
    
    if ( ! function_exists( 'ashe_excerpt' ) ) {
    
    	function ashe_excerpt( $limit = 50 ) {
    	    echo '<p>'. wp_trim_words(get_the_excerpt(), $limit) .'</p>';
    	}
    
    }

    But I don’t know why it causes this error. If I comment all the code from above out and change it to this, it works. @wprsupport Do you know why it make this error?

    // Filter the except length to 50 words.
    function ashe_excerpt_length( $length ) {
    	return 50;
    }
    add_filter( 'excerpt_length', 'ashe_excerpt_length', 999 );
    
    function ashe_excerpt() {
    
    	/**
    	 * Filters the displayed post excerpt.
    	 * @since 0.71
    	 * @see get_the_excerpt()
    	 * @param string $post_excerpt The post excerpt.
    	 */
    	echo apply_filters( 'ashe_excerpt', get_the_excerpt() );
    }

    Thread Starter bluewater2

    (@bluewater2)

    Thank you. I will send you an email.

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