• Hi, I am trying to check for a php variable in each of my template in order to assign it a different styling but the value seems to disappear, can you please help, I already spent hours trying to figure this out. I know there is something small I’m missing.

    So here is everything:

    I have a page a which links to b and pass a value in the URI as https://www.b.com/?value=h

    now the b file receive the value and change the global variable’s value to the one passed in the URI, then redirect back to the page.

    This is the code in my b file:


    $server = $_SERVER["REQUEST_URI"];
    $valuePos = stripos($server, "=");

    $nodes = substr($server, ($valuePos + 1));
    $endPos = stripos($server, "e");
    $gender = substr($server, ($valuePos + 1), ($endPos));

    $valuePos = stripos($nodes, "-");

    $redirecturl = substr($nodes, ($valuePos + 1));

    header( 'Location: '.$redirecturl );

    $gender is the global variable that I have declared in function.php, I have set its default value to neutral.

    Now when I try to access $gender from another template it just displays the default value (neutral). Please help

Viewing 2 replies - 1 through 2 (of 2 total)
  • I am trying to check for a php variable in each of my template in order to assign it a different styling

    Use the body_class() function on your theme’s header.php template file and each of your custom page templates will have its own unique class.

    Thread Starter rodrigue

    (@rodrigue)

    thanks esmi for your response. I already got a solution though. I used the $_SESSION class.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Assign and modify php values across templates’ is closed to new replies.