Skip to main content
Became Hot Network Question
Tweeted twitter.com/StackWordPress/status/1199704528439959553
edited title
Source Link

Pass a PHP variable to another templatefile

Is there a simple method to passing data from one templatefile 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); ?> 

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); ?> 

Pass a PHP variable to another file

Is there a simple method to passing data from one file 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); ?> 
Source Link

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); ?>