ygiv
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Hi,
If you change the code just a tiny bit you can add a “read more” with a link to the post at the end./** * Edit our excerpt output * */ /* add_filter( 'display_posts_shortcode_output', 'update_excerpt_format', 10, 7 ); function update_excerpt_format( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper ) { // First check if an excerpt is included by looking at the shortcode $atts if ( $atts['include_excerpt'] ) // Now let's rebuild the excerpt with the read more link at the end { $read_more ='<p><a href="'.get_permalink() . '"> Read More...</a></p>'; //Now we can truncate $excerpt = '<p><span class="excerpt">' . truncate_phrase( get_the_excerpt(), 150) . $read_more . '</span></p>'; } else $excerpt = ''; // Now let's rebuild the output. Only the excerpt changed so we're using the original $image, $title, and $date $output = '<' . $inner_wrapper . ' class="listing-item">' . $image . $title . $date . $excerpt . '</' . $inner_wrapper . '>'; // Finally we'll return the modified output return $output; } */ /** * Truncate Excerpt * */ function truncate_phrase($phrase, $max_characters) { $phrase = trim( $phrase ); if ( strlen($phrase) > $max_characters ) { // Truncate $phrase to $max_characters + 1 $phrase = substr($phrase, 0, $max_characters + 1); // Truncate to the last space in the truncated string. $phrase = trim(substr($phrase, 0, strrpos($phrase, ' '))); } return $phrase; }
Viewing 1 replies (of 1 total)