I posted up how I’m working in the end in this thread: ACF variables in blade template. Not specific to your query but more an answer to my original post.
In regards to your question, you would write that logic in your controller or you could create a new app/whatever.php
file, write your code as you would in a standard WordPress functions.php
file and then make sure to include your new file in resources/functions.php
, specifially in the below block:
array_map(function ($file) use ($sage_error) {
$file = "../app/{$file}.php";
if (!locate_template($file, true, true)) {
$sage_error(sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file), 'File not found');
}
}, ['helpers', 'setup', 'filters', 'admin', 'directives', 'whatever.php']);