Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: How do I show only excerpts in Twenty Seventeen theme?

Discussion in 'Misc WordPress Requests' started by jowaol1st, Feb 12, 2018.

  1. jowaol1st

    Guest

    Reply To: How do I show only excerpts in Twenty Seventeen theme?, by jowaol1st

    There are two ways I got this done (any of these will work):

    1.
    content.php is the file that controls this aspect, you should look to that file to change the_content to the_excerpt (for the right conditional tags).

    PS: If this affect the main post/page display, then you need a condition to be added, such as:

    if ( is_singular() ) {
    the_content();
    } else { the_excerpt(); }

    As you’ll have to change the theme’s code, make sure you’re working in a child theme.

    2.
    You can edit the theme OR the child theme functions.php file:

    /* Replace the content with excerpts on home page */
    add_filter( 'the_content', 'replace_content_with_excerpt', 100 );
    //http://wordpress.stackexchange.com/a/77947/25187

    /**
    * Return excerpt if we are not on a singular post view.
    *
    * @param string $content
    * @return string
    */
    function replace_content_with_excerpt( $content ) {
    if ( is_singular() ) {
    return $content;
    }

    // remove our filter temporarily.
    // Otherwise we run into a infinite loop in wp_trim_excerpt().
    remove_filter( 'the_content', __FUNCTION__, 100 );
    $excerpt = apply_filters( 'the_excerpt', get_the_excerpt() );
    add_filter( 'the_content', __FUNCTION__, 100 );
    return $excerpt;
    }

    Reply To: How do I show only excerpts in Twenty Seventeen theme?
     
    #1

Share This Page

Monarch Social Sharing Plugin