What exactly are you trying to accomplish here? It seems like you’re trying to pass an entire path to the blade loader, which is not necessary and may in fact be causing problems. Assuming your blades are in your theme folder, just include them based on their relative position inside views directory. I’m also not clear on why you’re swapping out _ and -. If you control the filenames for your blades (which I assume you do), why not just use _ and skip the str_replace() step? Then you could replace the 10+ lines of code you have above with
@include( 'blocks.' . get_row_layout() )
I don’t know for certain if the above is causing your issues, but it certainly could be since rendered blades are only generated when they’re requested and this rigamarole might be interfering with that.
I do that because dirname(__FILE__) gives an issue, which I believe could be roots problem, which I’ve made a post before. It gives the right file path, but wrong folder, or such, if that makes sense.
So for each project, which I already used this in my other project, I just hardcode the path, I just put XXX for the live server but this works as a code.
The other is just to keep naming conventions straight, since ACF creates this _ and in php I use -, so I just do that.
I have a different project using the exact same code, so I’m 100% sure this can’t be the issue. This is also compiled for FTP, so I believe, I might be wrong, that it should work like an normal wp theme right.
But this isn’t just appearing on the index/page this bug happens in every page.
So, if you go to settings, and permalinks, the error will appear, and you need to refresh, go to ‘read’ page, error will appear and you need to refresh, etc…
So it feels like it might be something else, since that there is definitelly not blade.