Support » Fixing WordPress » get_header include

  • Resolved mohrd


    Does get_header() include header.php content to the page?
    similar php include('header.php')?
    because, I wrote in header.php:
    <?php $abcd = "1234" ?>
    then wrote in index.php:

    echo $abcd;

    now in index page, I should see $abcd value (“1234”), but i can’t see it! and the $abcd is undefined in index.php .

    and how can I solve that problem?

    Thanks (sorry for bad English)

Viewing 3 replies - 1 through 3 (of 3 total)
  • add <?php global $abcd; ?> before you define $abcd

    but why wordpress needs global?

    To be honest I’m not sure. It’s isolated to the front end of WordPress. I used to encounter this issue a lot, and that’s the only way I know to fix it. I know that the function that gets used inside of the get_header() function is a require_once() but it’s still strange none-the-less.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get_header include’ is closed to new replies.