WordPress.org

Forums

Customizr
Change Length of Excerpt (8 posts)

  1. geologist
    Member
    Posted 1 year ago #

    How do I increase the length of the post excerpt that is displayed on the homepage? I have tried using the "More" button/code which has no affect.

    I'm guessing this must be specified in a php file. Please direct me to the correct file and function.

  2. rdellconsulting
    Member
    Posted 1 year ago #

    You need to add this to your functions.php in a child theme:

    function your_excerpt_length( $length ) {
        return 200;
    }
    add_filter( 'excerpt_length', 'your_excerpt_length' );

    Change 200 to what you need.

    Pls confirm this worked.

  3. geologist
    Member
    Posted 1 year ago #

    rdell consulting,

    I could not get this to work. I've been unable to get any code to work in my child theme functions.php file. So I'm assuming I'm making some basic mistake with the file. With your code, this is my entire functions.php file:

    <?php
    function your_excerpt_length( $length ) {
        return 400;
    }
    add_filter( 'excerpt_length', 'your_excerpt_length' ); 
    
    ?>

    When I upload this, my whole site blanks out.

  4. rdellconsulting
    Member
    Posted 1 year ago #

    Any chance there's a blank line after the ?>. I've seen that bring a site down before.

  5. geologist
    Member
    Posted 1 year ago #

    I've taken out everything that could possibly be read as a blank line and it still breaks the site. And yes, there was a blank line after the ?>.

    I realize this is bad programming, but can I safely put this function in the standard functions.php file somewhere?

  6. rdellconsulting
    Member
    Posted 1 year ago #

    Not good practice, and you'll lose it when you upgrade Customizr next time. Better to sort out why child theme not working.

    Your child theme should have 2 files - style.css and functions.php, assuming you've made no other changes. The header of the style.css should be as described here.

    customizr
    - files
    customizr-child
    - style.css
    -functions.php

    You need to activate the customizr-child theme in Appearance>Themes.

    Any change?

  7. geologist
    Member
    Posted 1 year ago #

    Thanks. My child css is working very well and the child theme has been activated for some time.

  8. shermansong
    Member
    Posted 1 year ago #

    I tried this code, too, but I'm not getting any excerpts to show. Do I need anything else in the functions.php file?

    CivicConsultingUSA.org

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic