Applying Conditional Styles to a Custom Template Using theme.json in WordPress
-
Hi there, I’m trying to find a way to achieve style parity between my custom template in the frontend, page editor and template chooser. I can do this for the page editor and front end successfully, but not the template chooser.
Currently, I’m using
enqueue_block_editor_assets
to conditionally load styles for my custom template withget_page_template_slug
. This works great on the frontend and the page editor. However, in the template chooser, the styles are not applied. I understand that this is because the rendering for the template chooser occurs client side and not server side so a method likeget_page_template_slug
is not going to be called as you navigate through the template chooser.
I’ve tried embracingtheme.json
to apply styles there instead of enqueueing assets with css the old way. However, I can’t find a way to include styles that only target my custom template.Can you help me find a way to add custom template styles in the template chooser? Thanks!
- The topic ‘Applying Conditional Styles to a Custom Template Using theme.json in WordPress’ is closed to new replies.