Okay
  Public Ticket #2182160
Category's post excerpt
Closed

Comments

  • Christine started the conversation

    Hi, How can I reduce the text excerpt to 55 words for example on category page. 

    Can you give a block of code that I should implement in function.php (child theme). 

    Actually I follow this post https://wpshout.com/wordpress-post-excerpts/

    But it only works for home page https://www.hotstylingtoolguide.com/

  •  958
    Marc replied

    Hi Christine,

    this should work on archive pages as well. Can you tell me the exact code you're currently using? Please click on the "TT" icon and select "Code" to insert code here.

    Best,
    Marc

  • Christine replied

    Hi Marc 

    I used the following: 

    function zuki_short_excerpts( $length ) {
    	// Don't change anything inside /wp-admin/
    	if ( is_admin() ) {
    		return $length;
    	}
    	// Set excerpt length to 55 words
    	return 55;
    }
    add_filter( 'excerpt_length', 'zuki_short_excerpts', 999 );
  •  958
    Marc replied

    Hi Christine,

    you're using the same priority as the parent theme's function. Because the parent theme's functions.php gets called after the child theme's the same priority results in using the parent theme's function.

    You can simply increase your priority by one to prevent this:

    function zuki_short_excerpts( $length ) {
        // Don't change anything inside /wp-admin/
        if ( is_admin() ) {
            return $length;
        }
        // Set excerpt length to 55 words
        return 55;
    }
    add_filter( 'excerpt_length', 'zuki_short_excerpts', 1000 );

    Best,
    Marc