Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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

    (@rexjaguarius)

    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

    (@jtsternberg)

    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

    (@rexjaguarius)

    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.