admin管理员组

文章数量:1125924

Does anyone know how I can insert a shortcode directly into a FSE template file, e.g. my-theme/templates/page-contact.html?

I have been trying [my_shortcode], but it does not seem to work.

If I try to add the shortcode to the template via the Appearance > Editor > Templates > page-contact it also does not work. However, if I add the shortcode directly into the page content, i.e. Pages > Contact and insert a shortcode block, then the shortcode [my_shortcode] works fine in the page.

I have the latest version of WP, currently 6.2.1. Working locally with Local By Flywheel.

I hope this makes sense, it has been rather puzzling to say the least as it was previously working. Tried all kinds of things like deactivating all plugins, using default twentytwentythree theme, etc, etc.

Many thanks for consideration.

Does anyone know how I can insert a shortcode directly into a FSE template file, e.g. my-theme/templates/page-contact.html?

I have been trying [my_shortcode], but it does not seem to work.

If I try to add the shortcode to the template via the Appearance > Editor > Templates > page-contact it also does not work. However, if I add the shortcode directly into the page content, i.e. Pages > Contact and insert a shortcode block, then the shortcode [my_shortcode] works fine in the page.

I have the latest version of WP, currently 6.2.1. Working locally with Local By Flywheel.

I hope this makes sense, it has been rather puzzling to say the least as it was previously working. Tried all kinds of things like deactivating all plugins, using default twentytwentythree theme, etc, etc.

Many thanks for consideration.

Share Improve this question edited May 17, 2023 at 20:25 nicknoop asked May 17, 2023 at 20:04 nicknoopnicknoop 113 bronze badges 3
  • The ability to do this was broken in 6.2.1: wptavern.com/… Whether it's restored is still an open question. – Jacob Peattie Commented May 18, 2023 at 7:31
  • Thanks @Jacob Peattie – nicknoop Commented May 18, 2023 at 8:07
  • Anyone stumbling onto this, here is a temp solution: core.trac.wordpress.org/ticket/58333#comment:7 – nicknoop Commented May 18, 2023 at 9:29
Add a comment  | 

2 Answers 2

Reset to default 2

This was a bug introduced in WordPress 6.2.1, and was resolved in WordPress 6.2.2.

Still a bug in some cases: https://github.com/WordPress/gutenberg/issues/35258

Places where shortcodes aren't working:

wp:pattern

wp:template-part

本文标签: full site editingUsing lt wpshortcode gtmyshortcodelt wpshortcode gt in FSE template file