WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Cannot Call a Variable defned in the Header (3 posts)

  1. goxu
    Member
    Posted 7 years ago #

    Hi,

    I put this in the header.
    <?php $test = 'test'; ?>

    And I put this in the sidebar,
    <?php echo $test; ?>

    But nothing happens. Why? Do I need to define a variable in every file?

  2. Kafkaesqui

    Posted 7 years ago #

    In header:

    <?php global $test; $test = 'test'; ?>

    In sidebar:

    <?php global $test; echo $test; ?>

  3. goxu
    Member
    Posted 7 years ago #

    Thank you so much, Kafkaesqui. I appreciate it.

Topic Closed

This topic has been closed to new replies.

About this Topic