• I have just installed the 2025 theme and I have a problem that excerpt block character count setting overrides all the Post excerpts I previously set manually. For example the sticky Welcome post has an excerpt that includes the whole post.

    My WordPress and plugins are up to date, but my host provider has not updated PHP beyond 7.4.33

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter raywarburton

    (@raywarburton)

    I have now realised it is picking up my manual excerpt, but applying the excerpt block limit. I use the html in some of my excerpts to include photos or link, but now I am getting uninterpreted html.

    Hi @raywarburton,

    I was able to reproduce this on a fresh WordPress 7.0 install (PHP 8.3), so this isn’t something specific to your site.

    What’s happening: the Post Excerpt block runs every excerpt — manual or auto-generated — through wp_trim_words() before rendering, and that function strips HTML tags as part of the trimming (via wp_strip_all_tags()), even when the excerpt is already within the word limit. In my test, a manual excerpt set via the sidebar “Post > Excerpt” field with a real <a> link rendered correctly as a hyperlink in the editor preview, but the published output was:

    <p class="wp-block-post-excerpt__excerpt">Venha descobrir o que temos aqui Lorem ipsum...</p>

    The <a> tag is gone, only its text content survived — and this happened even though the link text was well within the “Max number of words” setting, so it’s not a truncation side-effect.

    This is a know, currently open issue in Gutenberg core (github.com/WordPress/gutenberg/issues/49449). There’s an in-progress fix (PR #65209) that stops applying the length limit to custom excerpts specifically so formatting is preserved, but as of WordPress 7.0 it hasn’t been merged/released yet.

    If you’re comfortable adding a small snippet to a child theme (or a snippets plugin), you can override the block’s output for posts with a manual excerpt so it preserves the HTML instead of stripping it:

    add_filter( 'render_block', function ( $block_content, $parsed_block, $block ) {
    if ( 'core/post-excerpt' !== $parsed_block['blockName'] ) {
    return $block_content;
    }
    $post = ! empty( $block->context['postId'] ) ? get_post( $block->context['postId'] ) : null;
    if ( ! $post || empty( $post->post_excerpt ) ) {
    return $block_content;
    }
    $safe_excerpt = wp_kses_post( $post->post_excerpt );
    $new_content = preg_replace(
    '/(<p[^>]*class="[^"]*wp-block-post-excerpt__excerpt[^"]*"[^>]*>).*?(<\/p>)/s',
    '$1' . $safe_excerpt . '$2',
    $block_content,
    1
    );
    return $new_content ?: $block_content;
    }, 10, 3 );

    This is a workaround, not an official fix, it only kicks in for posts that have a manual excerpt, so auto-generated excerpts keep the normal (safer) trimming behavior.

    Hope this helps clarify what’s going on!

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.