Excerpt in Twenty Seventeen

The new version of WP appeared very interested theme Twenty Seventeen.

But for me need blog style with excerpts without full content.

And I created child theme and added code in functions.php

function the_content_loop_trim($content){

  if(is_archive() or is_home()){
    $post = get_post();
    $content = $post->post_content;
    $url = get_permalink($post->ID);
    $more = sprintf(' <a href="%s">...</a>', $url);
    $excerpt = wp_trim_words( $content, $num_words = 30, $more);
    $content = $excerpt;
  }

  return $content;
}
add_filter('the_content', 'the_content_loop_trim');
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s