admin管理员组

文章数量:1302405

I'm fairly new to WP dev and I'm trying to work out the best method to include reusable sections/templates within the page content added within the page editor. I have included an image to illustrate what I mean:

The content highlighted in green is added to the page via the editor. What I want to know is, how do I split up those sections with reusable sections/includes. Obviously, I can just added the markup into the page content but I assume there is a much better way of doing it?

I have been reading about shortcodes, is that the best way to approach this? If correct, I guess the best way would be to create template partials (or whatever the correct term is) for each reusable section, then create shortcode functions for them in the functions.php. Then add them to the page content using shortcodes?

Hope this makes sense.

Thanks

I'm fairly new to WP dev and I'm trying to work out the best method to include reusable sections/templates within the page content added within the page editor. I have included an image to illustrate what I mean:

The content highlighted in green is added to the page via the editor. What I want to know is, how do I split up those sections with reusable sections/includes. Obviously, I can just added the markup into the page content but I assume there is a much better way of doing it?

I have been reading about shortcodes, is that the best way to approach this? If correct, I guess the best way would be to create template partials (or whatever the correct term is) for each reusable section, then create shortcode functions for them in the functions.php. Then add them to the page content using shortcodes?

Hope this makes sense.

Thanks

Share Improve this question asked Mar 10, 2021 at 9:59 BurnsBurns 32 bronze badges 2
  • I would create a gutenberg bloc, which then you can use as a reusable bloc, what excatly do you want to have inside those blocs ? – lucrece Commented Mar 10, 2021 at 10:19
  • Hi, thanks. They are just blocks of content (html, images) like CTAs, feature lists, faqs etc) that might be included in other pages. Did you mean Gutenberg block? – Burns Commented Mar 10, 2021 at 10:26
Add a comment  | 

1 Answer 1

Reset to default 1

I think you should to take a look at the gutenberg bloc.

This is not simple at the first approach, but I think you should take a look at it (even if you want to use some plugin to help you)

See the doc : https://developer.wordpress/block-editor/

本文标签: shortcodeBest way to include reusable sections in page content