You seem to be making the assuming that Blade’s @include is equivalent to PHP’s include() which is not the case. Blades receive variables from two places (AFAIK):
- The controller (or controller-like structure)
- Variables which are directly passed to them
The second is done as follows: @include('partials.some-blade', array('variable_name' => $variable_data).
IMO your problem is because you are treating Blade as if it is just PHP, not a templating language. Setting variables in your Blades will not always work the way you want for this reason. To allow for some of Blade’s features, your Blade is not simply executed top to bottom, pulling in all partials, as you might see in a plain PHP script. Your variable, whatever it is, should be set at the controller level (either with Controller, or with Sage’s filters). I don’t understand what it is your code is meant to accomplish, so it’s difficult for me to suggest how you might accomplish it. I lean toward processing my own data at the controller level, and sending on the data I need (instead of relying on WordPress’s loops). Here is a post I made about that technique.