- This topic has 3 replies, 1 voice, and was last updated 1 year, 11 months ago by Tom.
May 18, 2020 at 2:21 am #1289683Natalie
If your page starts with a GenerateBlocks grid, nested containers, or a headline inside a container then the excerpt that WordPress auto-generates is blank. I noticed this issue on the search results page where a lot of my excerpts were blank.
Some of my pages have nested containers
I have looked at the WP (and GB) code and can see why this is happening.
WP only allows certain types of blocks when parsing the page trying to extract an excerpt.
GB has defined the container and headline blocks as ‘allowed’ blocks for their contents to be used in the excerpt.
BUT if the container or headline block are ‘inner’ blocks – i.e. they are inside another block (e.g. a container), then WP will not parse them when constructing the excerpt.
This is because the list of ‘inner’ blocks that WordPress will parse is fixed and cannot be modified by a plugin (WP has no filter for the list)
So GB is unable to tell WordPress that container and headline blocks are allowed ‘inner’ blocks.
WP are aware of this issue (and have been for 11 months!) and other block plugin authors have the same problem.
Tom – I’m sure you’re aware of this, and presumably there is no workaround at the moment.
I’m posting here to help others with the same issue, so they don’t spend a whole day trying to work out why some of their excerpts are blank!
I’m trying to rethink my page structure to avoid nested containers, but you can’t really control what a client will add to the page, so my best solution at the moment is to manually define an excerpt for the page.
To do that you need to enable the Excerpt box for pages in functions.php:
add_post_type_support( 'page', 'excerpt' );May 18, 2020 at 11:50 am #1290655TomLead DeveloperLead Developer
Thanks for posting this! We are aware, and as you found I did my best to at least include basic containers/headlines in the excerpt.
I think the manual excerpt method is the best way forward for now until Gutenberg figures it out.
Thanks again!May 18, 2020 at 6:04 pm #1291009Natalie
ThanksJune 9, 2020 at 7:23 pm #1321454TomLead DeveloperLead Developer
- You must be logged in to reply to this topic.