Skip to content

Commit

Permalink
fixes the read more added by themes in latest posts block rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed Feb 28, 2020
1 parent 4ea0668 commit cdeee6f
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions packages/block-library/src/latest-posts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @return string Returns the post content with latest posts added.
*/
function render_block_core_latest_posts( $attributes ) {
global $post;

$args = array(
'posts_per_page' => $attributes['postsToShow'],
'post_status' => 'publish',
Expand All @@ -30,6 +32,7 @@ function render_block_core_latest_posts( $attributes ) {
$list_items_markup = '';

foreach ( $recent_posts as $post ) {

$list_items_markup .= '<li>';

if ( $attributes['displayFeaturedImage'] && has_post_thumbnail( $post ) ) {
Expand Down Expand Up @@ -83,21 +86,9 @@ function render_block_core_latest_posts( $attributes ) {
$trimmed_excerpt = get_the_excerpt( $post );

$list_items_markup .= sprintf(
'<div class="wp-block-latest-posts__post-excerpt">%1$s',
'<div class="wp-block-latest-posts__post-excerpt">%1$s</div>',
$trimmed_excerpt
);

if ( strpos( $trimmed_excerpt, ' &hellip; ' ) !== false ) {
$list_items_markup .= sprintf(
'<a href="%1$s">%2$s</a></div>',
esc_url( get_permalink( $post ) ),
__( 'Read more' )
);
} else {
$list_items_markup .= sprintf(
'</div>'
);
}
}

if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent']
Expand Down

0 comments on commit cdeee6f

Please sign in to comment.