Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress How to Build a WordPress Plugin Building a WordPress Plugin Settings Page CRUD with the WordPress Options Table

Alessandro Muraro
Alessandro Muraro
15,457 Points

How do variables go from one page to the other?

Sorry for the maybe dumb question, but I'm following the lesson, and there's one thing I can't quite grasp.

I see that in the wptreehouse-badges.php file, I have code to set the submitted option to the variable $wptreehouse_username

I am fine with this, what I don't entirely understand is how the options-page-wrapper.php page can "understand" the value of that same $wptreehouse_username variable when called. How does it "know" this variables value? I hope this is clear enough.

Many thanks!

2 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi, we set this in the function that calls the template to load. So if we set the variables in the function then call the template, the template will be able to access those variables :)

Alessandro Muraro
Alessandro Muraro
15,457 Points

Ah yes, because we include the options-page-wrapper.php - right?