Support » Developing with WordPress » Font problem in excerpt

  • Hello
    By default, excerpt length in wordpress is set to 55 words.
    I would like to show an excerpt by specifying a maximium number of characters, instead of maximium number of words.
    So, I used the following code in function.php (I saw it in codex.wordpress.org)

    
    function the_excerpt_max_charlength($charlength) {
    	$excerpt = get_the_excerpt();
    	$charlength++;
    
    	if ( mb_strlen( $excerpt ) > $charlength ) {
    		$subex = mb_substr( $excerpt, 0, $charlength - 5 );
    		$exwords = explode( ' ', $subex );
    		$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
    		if ( $excut < 0 ) {
    			echo mb_substr( $subex, 0, $excut );
    		} else {
    			echo $subex;
    		}
    		echo '[...]';
    	} else {
    		echo $excerpt;
    	}
    }

    Then, I add “the_excerpt_max_charlength(200);” to the content.php.
    The code was implemented correctly.
    But I have a problem: The font that I used in theme, In post excerpt section changed to wordpress default font.

    I will appreciate your help.

    • This topic was modified 5 years, 4 months ago by zimaa1991.
    • This topic was modified 5 years, 4 months ago by zimaa1991.
    • This topic was modified 5 years, 4 months ago by zimaa1991.
    • This topic was modified 5 years, 4 months ago by zimaa1991.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Font problem in excerpt’ is closed to new replies.