1. Tomas Mackevicius

    “There is no way to contextually load different template parts.” – is it possible to improve WP to address this issue?


    • Justin Tadlock

      On the front end, it should be relatively easy with a filter on the block itself. In the editor, I’m not sure. I don’t know how you’d get whatever context you need (current post, current query, etc.). That’s where I’ve hit problems.


  2. Bobby Thompson

    As someone who is trying to find my footing, your posts have been super valuable lately.


  3. Steve Grant

    This doesn’t really fit in with the survey but I found that manually editing JSON files for complex themes soon become unwieldy. Even with my closures indicated by my editor I soon get lost in the nested elements.

    Rather than a manual JSON edit it’s easier of course to create the layout in the (new) WP theme editor and export the JSON from there, that process is actually very simple. Thankfully.

    But it demonstrates my point:
    I think theming in JSON was chosen for it’s simplicity and legibility – which seems true at first but once we start building complex themes it becomes labyrinthine and really relies on our tooling to create coherent valid outcomes. So with that reliance on tooling the output format becomes a black box, and could have been any file really! It could have been SQL!

    I’m not sure I have an actual point, just that observation: JSON loses legibility after a certain depth of complexity and loses the supposed benefits of direct text editing, it starts to rely on the WYSIWYG JSON theme editor. Which may be fine. It depends on use cases.


    • Justin Tadlock

      I’m right there with you. That’s one of the reasons I think it’d be nice to have a method for doing this via PHP, which would allow theme devs to organize and manage this in a way that makes sense to them.

      Currently, I am splitting my theme.json into multiple JSON files and merging them with this webpack script, but that method makes the barrier to entry for new devs much higher. At least it keeps me sane for the moment though.


      • Steve Grant

        Hi Justin.
        There were some older GitHub tickets discussing the need for script in templates. I’m not really sure why we found ourselves without script in template files when the need seems obvious, and limitations seem arbitrarily puritanical.

        Way back in Nov 2020 before FSE was finalised there was some discussion around the partials format and the necessity to include logic which implied PHP ought to be the format of choice. Yet today we have only flat html template files, and even inline scripting conditionals don’t seem to work (last I checked).

        I had to stop developing FSE themes about 6 weeks ago because required conditionals. It was overkill to build the conditional into an extended core block pattern where it could have been achieved with 20 characters in header.html

        I have a strong feeling that there’s a fashionable distaste for PHP, and there are some “babies being thrown out with the bathwater”.

        Here’s the old discussion about flat html Vs PHP templates.

        I’m not sure who took the ultimate decision to kill scripting in templates, and why that is the preferred limitation. I’m not sure if scripting is coming, or if this is closed.


  4. Anne McCarthy

    Justin! As always, thank you for participating in the survey and encouraging others to do the same. I imagine you sharing this article is part of why there are 25+ responses already :) Speaking personally, it’s immensely helpful to read someone’s long form thoughts to the survey questions as it’s easy to only get condensed answers in return. Stay tuned for the full write up.


Comments are closed.

%d bloggers like this: