I am currently working on a plugin, and I want to add a settings page. I've already found out how to create the settings page, but how do I get the content from the settings page into a variable so I can use it?


In your options page each field should be put into an options array. For Example:

When you registered your settings page you should have used a code like this:

register_setting( 'pluginPage', 'rt_fed_settings', 'rt_validate');

Once on your page where you want to call settings, use this code:

$options_fed = get_option('rt_fed_settings'); // this is calling your settings array into a variable called options_fed.

Now to call items from it you would call them just like any array items:


The array items were set in your plugins page, but if you want see what is in the code you can use print_r.

  • I used register_setting("member_only_fields", "loginURL");, so what would I use? options = get_option("member_only_fields") then $options["loginURL"]doesn't work – NerdOfLinux Aug 14 '17 at 18:53
  • That seems right to me! – rudtek Aug 14 '17 at 18:54
  • It returns nothing, but when I return to the settings page, it's still there, so its saving. – NerdOfLinux Aug 14 '17 at 18:55

Turns out it a lot simpler than I though. When you use register_setting("something", "name") then to get it in the plugin, just use get_option("name").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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