Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #59348, comment 2


Ignore:
Timestamp:
09/14/2023 12:33:06 PM (2 years ago)
Author:
frzsombor
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #59348, comment 2

    initial v1  
    55function filter_metadata_registration( $metadata ) {
    66    if ($metadata['name'] === 'core/post-excerpt') {
    7         $metadata['attributes']['excerptLength'] = 40; //ANY NUMBER
     7        $metadata['attributes']['excerptLength'] = [
     8            'type' => 'number',
     9            'default' => 9999,
     10        ];
    811    }
    912    return $metadata;
     
    1114add_filter( 'block_type_metadata', 'filter_metadata_registration' );
    1215}}}
    13 
    14 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
    15 
    16 {{{
    17 array (size=2)
    18   'showMoreOnNewLine' => boolean true
    19   'excerptLength' => int 55
    20 }}}
    21 
    22 to be
    23 
    24 {{{
    25 array (size=1)
    26   'showMoreOnNewLine' => boolean true
    27 }}}
    28 
    29 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.