[wp-trac] [WordPress Trac] #59348: Excerpt block length is not full customizable any more
WordPress Trac
noreply at wordpress.org
Thu Sep 14 12:23:23 UTC 2023
#59348: Excerpt block length is not full customizable any more
-------------------------------+------------------------------
Reporter: frzsombor | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------------+------------------------------
Comment (by frzsombor):
Update:
I just found a way to edit default block settings with "Block Hooks"
(block filters), for example:
{{{
function filter_metadata_registration( $metadata ) {
if ($metadata['name'] === 'core/post-excerpt') {
$metadata['attributes']['excerptLength'] = 40; //ANY NUMBER
}
return $metadata;
};
add_filter( 'block_type_metadata', 'filter_metadata_registration' );
}}}
However, strangely enough, this code makes the "excerptLength" completely
disappear from the attributes (when printed out in
`render_block_core_post_excerpt` of post-excerpt.php) making the original
{{{
array (size=2)
'showMoreOnNewLine' => boolean true
'excerptLength' => int 55
}}}
to be
{{{
array (size=1)
'showMoreOnNewLine' => boolean true
}}}
Which is cool for me, because at least I get "unlimited excerpts" but this
is either a bug or I'm missing something, so I'm opening a ticket on this
too.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59348#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list