Timeline for How to extract 'intro' block from page content, but later strip from page main content
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 3, 2023 at 19:51 | history | edited | Visnetje | CC BY-SA 4.0 |
added 8 characters in body
|
Apr 3, 2023 at 19:51 | answer | added | Visnetje | timeline score: 1 | |
Apr 3, 2023 at 19:34 | comment | added | Visnetje |
@TomJNowell , I managed to fix the issue by applying the render_block filter after having rendered the intro block, and right before calling the_content() . I will post the solution below, perhaps it can help others, as well. Thanks again for suggesting to drop the_content in favor of the render_block filter.
|
|
Apr 3, 2023 at 17:34 | comment | added | Visnetje |
@TomJNowell , appreciate the note. I have actually tried using the render_block filter. But how can I differentiate between rendering it for the intro section, and skipping it for the page content?
|
|
Apr 3, 2023 at 16:07 | comment | added | Tom J Nowell♦ |
note that there are filters that WP calls when rendering a block that allow you to override it, you don't need to mess around with regex parsing or the_content filter when you can run a test to see if the block should show and do return "" if it shouldn't
|
|
S Apr 3, 2023 at 15:22 | review | First questions | |||
Apr 17, 2023 at 15:26 | |||||
S Apr 3, 2023 at 15:22 | history | asked | Visnetje | CC BY-SA 4.0 |