Conversation
supportI have deactivated all other plugins except Rank Math SEO and switched back to the default theme. It seems that shortcodes are not rendered correctly in post-excerpt and meta description. Any suggestions?
Thanks for the report. I can confirm that this is the case. It hasn’t been tested a lot with FSE themes. I will start working on an update to improve this.
Here is what I found: 1. WordPress deletes shortcodes from auto-generated excerpts. But if you use a custom excerpt https://cln.sh/v8w0vzYqGCFbmJfP9X2n you will get the desired output. Note that this is a core feature . 2. Once you do that, Rank Math loads the meta description correctly as well. Please let me know if this works for you.
Thanks for the tips! I found the related code: https://github.com/WordPress/WordPress/blob/239f2e0f0c9b96ae030823e2169c997ecc839ca8/wp-includes/formatting.php#L3956-L3957 It seems that we don’t have a proper filter before calling strip_shortcodes . A possible solution is to replace the default wp_trim_excerpt filter in the get_the_excerpt hook and remove the strip_shortcodes from it.
Maybe we can exclude our shortcodes from being stripped via strip_shortcodes_tagnames hook. Also, it seems that strip_shortcodes is only being used in wp_trim_excerpt in wp core. The purpose is to avoid rendering unexpected blocks. But our dynamic date shortcodes only render inline text, so it should be safe to keep them.
Nice ideas. Implemented. Please update to 1.3.9 and let me know if something is still broken.
Great! Thanks. I saw your commit on Github. I fact I also created a PR but didn’t know the github repo was not up to date. BTW I saw something may need to be improved in your new commit: .DS_Store files should be excluded from git repo Using array_search inside a loop might not be an optimized solution. Some options: Using array_diff directly – simpler to implement Replace array_search with a hash map to improve performance. See this
Thank you. And yes, I don’t keep SVN and Github in sync but will try from now and on. Pushed a new updated.
Thanks for the report. I can confirm that this is the case. It hasn’t been tested a lot with FSE themes. I will start working on an update to improve this.
Here is what I found: 1. WordPress deletes shortcodes from auto-generated excerpts. But if you use a custom excerpt https://cln.sh/v8w0vzYqGCFbmJfP9X2n you will get the desired output. Note that this is a core feature . 2. Once you do that, Rank Math loads the meta description correctly as well. Please let me know if this works for you.
Thanks for the tips! I found the related code: https://github.com/WordPress/WordPress/blob/239f2e0f0c9b96ae030823e2169c997ecc839ca8/wp-includes/formatting.php#L3956-L3957 It seems that we don’t have a proper filter before calling strip_shortcodes . A possible solution is to replace the default wp_trim_excerpt filter in the get_the_excerpt hook and remove the strip_shortcodes from it.
Maybe we can exclude our shortcodes from being stripped via strip_shortcodes_tagnames hook. Also, it seems that strip_shortcodes is only being used in wp_trim_excerpt in wp core. The purpose is to avoid rendering unexpected blocks. But our dynamic date shortcodes only render inline text, so it should be safe to keep them.
Nice ideas. Implemented. Please update to 1.3.9 and let me know if something is still broken.
Great! Thanks. I saw your commit on Github. I fact I also created a PR but didn’t know the github repo was not up to date. BTW I saw something may need to be improved in your new commit: .DS_Store files should be excluded from git repo Using array_search inside a loop might not be an optimized solution. Some options: Using array_diff directly – simpler to implement Replace array_search with a hash map to improve performance. See this
Thank you. And yes, I don’t keep SVN and Github in sync but will try from now and on. Pushed a new updated.