Title: Return array from Theme Options MetaBox/Timber Twig
Last modified: August 30, 2016

---

# Return array from Theme Options MetaBox/Timber Twig

 *  Resolved [rexjaguarius](https://wordpress.org/support/users/rexjaguarius/)
 * (@rexjaguarius)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/return-array-from-theme-options-boxtimber-twig/)
 * I have created the options and settings page for my theme using the code in the
   snippet library: [https://github.com/WebDevStudios/CMB2-Snippet-Library/tree/master/options-and-settings-pages](https://github.com/WebDevStudios/CMB2-Snippet-Library/tree/master/options-and-settings-pages)
 * I am also using the timber/twig framework, so what I want to do is retrieve the
   entire array of values from the theme options box so that I can pass it to my.
   twig view.
 * I can’t seem to find anything about this. Is there an easy way to return an array
   of all field values/keys for a particular metabox (theme options page in this
   case) so I can assign it to a variable?
 * [https://wordpress.org/plugins/cmb2/](https://wordpress.org/plugins/cmb2/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 6 months ago](https://wordpress.org/support/topic/return-array-from-theme-options-boxtimber-twig/#post-6757581)
 * The mentioned “myprefix_get_option( ‘test_text’ )” in the readme should be a 
   good first step. Note that you may have renamed the “myprefix” part and if you
   did, change it to whatever you renamed it to. You may need to call it a number
   of times to get all the specific options you want from it, but those could all
   be appended to the same variable.
 *  Thread Starter [rexjaguarius](https://wordpress.org/support/users/rexjaguarius/)
 * (@rexjaguarius)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/return-array-from-theme-options-boxtimber-twig/#post-6757593)
 * Thanks for your reply Michael.
 * Maybe this could be a feature request then? I would be great to be able to reference
   a particular metabox like that and pull an array of the values, especially for
   use with a library like Timber.
 * Is cmb2 not a good option for an admin panel? I’d like to be able to do things
   like tabbed options pages or separate collapsible metaboxes but I don’t think
   I can — maybe I’m just trying to avoid the work of doing it through the wordpress
   api?
 * Great plugin/library btw, love it – especially the repeating fields!
 *  Plugin Author [Justin Sternberg](https://wordpress.org/support/users/jtsternberg/)
 * (@jtsternberg)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/return-array-from-theme-options-boxtimber-twig/#post-6757599)
 * Since myprefix_get_option returns the result of:
 *     ```
       cmb2_get_option( myprefix_admin()->key, $key );
       ```
   
 * (where “myprefix_admin” should have been replaced with your prefix), you can 
   instead use:
 *     ```
       $all_options = cmb2_options( myprefix_admin()->key )->get_options()
       ```
   
 * Re: metaboxes/tabbed UI, etc, yes, you could do it, but you’ll have to be familiar
   with the markup/apis which drive those features.
 *  Thread Starter [rexjaguarius](https://wordpress.org/support/users/rexjaguarius/)
 * (@rexjaguarius)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/return-array-from-theme-options-boxtimber-twig/#post-6757614)
 * Awesome! I created a new function to do that. I had looked at cmb2_options but
   I was missing the ->get_options() at the end.
 * Thanks for the help guys, keep on it – this is one of the best additions to wordpress
   imo, most especially since it is open source.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Return array from Theme Options MetaBox/Timber Twig’ is closed to new
replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [rexjaguarius](https://wordpress.org/support/users/rexjaguarius/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/return-array-from-theme-options-boxtimber-twig/#post-6757614)
 * Status: resolved