-
Hi there! I'm working on a project where I need to filter Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @catkit, Sorry for the late reply. I think what you want to do can be solved by the following approach:
Here is a sample: add_filter( 'render_block_core/post-content', function ( $block_content, $block ) {
// For the post content block that doesn't have a class name, output the content as is.
if ( ! isset( $block['attrs']['className'] ) ) {
return $block_content;
}
// For the post content block that doesn't have a specific class name, output the content as is.
if ( 'your-class' !== $block['attrs']['className'] ) {
return $block_content;
}
// For the post content block that has a specific class name, add contents.
return $block_content . '<p>additional contents</p>';
}, 10, 2 ); |
Beta Was this translation helpful? Give feedback.
-
Hi @t-hamano !
No worries! Thanks for taking the time to answer me! I didn't know about this filter! I'll try it next time I need to change how a block is rendered! |
Beta Was this translation helpful? Give feedback.
Hi @catkit,
Sorry for the late reply.
I think what you want to do can be solved by the following approach:
Here is a sample: