Comments (4)
@Bowriverstudio if I understand you right, you want to use something like this in your theme's html files to include template parts:
<!-- wp:template-part {"slug":"name-of-template-part-file-without-extension","theme":"your-theme-name"} /-->
This is how the index.html
file in the parisienne
theme includes its header
:
https://github.com/WordPress/theme-experiments/blob/master/parisienne/block-templates/index.html#L2
from theme-experiments.
Hi John, thanks for the answer. I've got a custom post type in a plugin and want to include a template part that is not in the child theme folder. Does that make sense?
from theme-experiments.
I traced the code for template-part inclusion back to here:
https://github.com/WordPress/gutenberg/blob/21304f999b1cbcc53d8ad098d297a6e9cf049e69/packages/block-library/src/template-part/index.php#L33
It doesn't look like there's any handling there for template files that would exist outside of a theme, so the only way I can see to do that would be to programmatically insert a post with the post_type set to wp_template_part
and the slug set to match what your theme is calling as the slug.
In this case it would be the word "header", but I guess you could call it whatever you want. For example:
<!-- wp:template-part {"slug":"slug-of-your-programmatically-created-template-part","theme":"your-theme-name"} /-->
from theme-experiments.
Thank you for your help John. I think I'll just include the code I'd normally put in a plugin, in the theme for now.
from theme-experiments.
Related Issues (20)
- 404 for "theme.json Documentation" link in readme.md
- TT1 Blocks: Separator styled differently in editor vs published site HOT 4
- TT1 Blocks: Media and Text Block is stretched at the frontend HOT 5
- TT1 blocks: Enable margin support in theme.json for 10.7 HOT 4
- Recreate Twenty Twenty Blocks as a universal or hybrid theme? HOT 5
- Button block lacks spacing when added to a columns block HOT 1
- Feedback on creating a blank template and spacing HOT 1
- Update TT1 Blocks to 0.4.7 and re-upload to the theme repository HOT 1
- TT1 Blocks: Settings -> general HOT 3
- correct the slug/folder name for Empty theme HOT 2
- Navigation Block Spacing Issue HOT 2
- TT1 Blocks: Search Block background color doesn't update HOT 3
- Feedback on trying to remove padding between template part and cover block HOT 2
- emptytheme Does nothing? HOT 1
- TT1 blocks: missing visuals for gradients HOT 1
- TT1 blocks: Multiple <h1> HOT 4
- New empty theme : Fatal error Uncaught UnexpectedValueException HOT 1
- TT1 Blocks: Visual issues HOT 2
- TT1 blocks: Implement elements API
- alomiz.com HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from theme-experiments.