WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

global $lineOne;

Messy way of coding though.

share|improve this answer
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 Mar 27 '13 at 22:00
This is really general PHP stuff rather than WordPress... – vancoder Mar 27 '13 at 22:11
but isn't there something that I can write to get the string from the database? like get_option – MadsRH Mar 27 '13 at 23:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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