I’m not experienced in twig and I’m trying to get my site updated to work with php8.4. When i updated it from php8.2 to 8.4 it broke and appeared to be due to the twig version not working with php8.4.
So I manually updated the twig and timber files and the bit that was broke then worked but it broke the accordians and galleries.
I noticed that now for some reason the structure was incorrect as it was now loading the metadata and scripts at the top of the page before the tag.
Is there any obvious reason for this or logical steps to work out what is happening?
I have a base.twig file that extends a sitesetup.twig in the templates->scaffolding folder.
I’m confused though as there is an overrides folder that also contains a scaffolding folder, and also a sub folder that that has a templates folder with another scaffolding folder. Does any of this sound normal, I don’t know why there are numerous scaffolding folders? I don’t know if this is normal twig setup?
Ah. So I’ve replaced the twig files again but with 3.27.1 and that seems to have fixed the issue. I had previously used v4. so there must be something in V4 that is not compatible with the coding on my site. I guess for now as long as it is stable on v3 and PHP8.4 then I’ll live with it.
A move from PHP 8.2 to 8.4 should’t suddently cause Meta, link, script tags to render before the html or head unless something in the template hierarchy or output buffering has changed.
A few things I’d check first:
1. Verfity Your Timber/Twig Version
Simply replacing the vendor file manually can cause compatibility issues if the project was built against a specific timber version. Check that your wordpress version, Timber version, Twig version, and PHP 8.4 are actually compatible with each other.
2. Find where is actually rendered.
If wp_head() is being called before the opening HTML structure, WordPress will output all of its metadata their.
3. Check the Twig inheritance
Since your mentioned base.twig extends sitesetup.twig, verify the inheritance chain.
I want to tell you which direction things goes.
One other thought : If you manually upgraded Twig/Timber instead of updating them via Composer, there’s a reasonable chance you’ve ended up with a version mismatch rather than a PHP 8.4 issue. Timber changed quite a bit between major releases.
I worked with Adult SEO Minds, where we maintain Wordpress sites with custom Timber/Twig themes alongside SEO work. We’ve seen similar issues after framework upgrades, and in many cases the root cause turned out to a template override being loaded unexpectedly or an incompatible Timber version rather than PHP itself.