WordPress.org

Ready to get started?Download WordPress

Forums

including global varialbes? (2 posts)

  1. Zoom123
    Member
    Posted 7 years ago #

    How can I include a global variable with a plugin (or even directly in the template)?

    I noticed that if in the header.php I create a variable $x = "something"; then if I try to echo this variable from another part of the template (e.g. in the index.php) then that variable doesn't exist. I tried setting it to global but it didn't work either.

  2. pizdin_dim
    Member
    Posted 7 years ago #

    Have you tried using $GLOBALS['x']? That will work, irrespective of whether you're in a function or not.

Topic Closed

This topic has been closed to new replies.

About this Topic