Skip to main content
1 of 2

Pass a PHP variable to another template

Is there a simple method to passing data from one template to another? I'm new to PHP and can't find a simple answer to my problem online. Apologies if this has been answered a million times & thanks in advance.

My Template 

<?php

// Declare a variable with the name of the file I want to pull in 
$critical_css = 'style';

// Header
get_header();

?>
Header 

// Get php file with inline style written inside
<?php get_template_part('/path/to/' . $critical_css); ?>