I know the data I want is stored as $lineOne and I can echo that inside the function. But I want to get the data outside of the function.

I've tired:


Here's the code where I want to insert $lineOne (line 11) and the widget where the variable is loaded/saved: http://pastie.org/7142717

  • 1
    You do that already. What is your question?
    – fuxia
    Commented Mar 27, 2013 at 21:16
  • toscho -> I do what? If I move the PHP echo code outside the function, it returns nothing
    – MadsRH
    Commented Mar 27, 2013 at 21:20
  • 2
    This is a PHP question not a WordPress one. @MadsRH, you should look into scope.
    – s_ha_dum
    Commented Mar 28, 2013 at 4:17
  • This is not a WP question...
    – Dan
    Commented Mar 28, 2013 at 5:22

1 Answer 1


You'd need to declare $lineOne as global inside your function:

global $lineOne;

Messy way of coding though.

  • Thanks, I've tired to add global $lineOne; just at the start of the function, but I still cannot echo it outside. Any suggestion regarding the coding style is recived with applause.
    – MadsRH
    Commented Mar 27, 2013 at 22:00
  • 1
    This is really general PHP stuff rather than WordPress...
    – vancoder
    Commented Mar 27, 2013 at 22:11
  • but isn't there something that I can write to get the string from the database? like get_option
    – MadsRH
    Commented Mar 27, 2013 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.