- This topic has 4 replies, 2 voices, and was last updated 1 year, 4 months ago by
Joey.
-
AuthorPosts
-
May 18, 2020 at 2:21 am #1289683
Natalie
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 containersI 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.
ref: https://core.trac.wordpress.org/ticket/47637Tom – 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 #1290655Tom
Lead DeveloperLead DeveloperHi Natalie,
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
Thanks
June 9, 2020 at 7:23 pm #1321454Tom
Lead DeveloperLead DeveloperJust circling back on this. It’s a WP issue that needs to be addressed: https://core.trac.wordpress.org/ticket/47637
August 3, 2022 at 6:19 pm #2302630Joey
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
So I spent about a day trying to figure this out, haha I came to the same solution. I wish I would have seen this post first. But apparently it’s still a WP issue in 2022.
-
AuthorPosts
- You must be logged in to reply to this topic.