I have my wordpress page where I want to pass value between header.php and style.php(php version of style.css) files.
In header.php I have:
<?php $background = get_field('background')['url']; ?>
Which retrieves custom field value(uploaded img url).
In my style.php I have my css, but before that I have my <?php ?>
tag where I can define some variables to use in stylesheet. Any ideas, how to retrieve this value from header.php and store in a variable on style.php?
Any help is very much appreciated, thanks.
If I follow you correctly, you’re essentially wanting to have more control over the background image in CSS, but need to be able to allow the user control on the backend to define it.
In that case I would do something simple in the
header.php
<head>
like,in the CSS file you can govern the rest of the control of the element.
Here’s a real-world example of what I did today on a site.
In my head:
My HTML:
My CSS:
If you’re attempting to define a GLOBAL variable, then you put this above your variable:
<?php global $background; ?>
Then you can use $background on any other page (but if it’s being used in the header, then it’s already accessible on other pages since that’s a template part).
Answering the question that you asked and not the problem that you have,
You’d use
$_REQUEST
: