How to pass a variable to get_template_part that’s updated every time the template part is called?
I found an easy solution. Replacing <?php get_template_part ( ‘loop’) ?> with <?php include( locate_template( ‘loop.php’, false, false ) ); ?> did the trick. I could just use the variable as I usually would. Code and answer from mekshq.com.