Skip to content

Instantly share code, notes, and snippets.

@yojance
Created July 20, 2014 01:50
Show Gist options
  • Save yojance/857675b29387eb9bc7c3 to your computer and use it in GitHub Desktop.
Save yojance/857675b29387eb9bc7c3 to your computer and use it in GitHub Desktop.
OptionTree Sidebar Select Option Type
// OptionTree Sidebar Select Option Type
// Example code when being used as a Metabox or
// Exported OptionTree file to be used in Theme Mode
// This option type will read all of your available
// Sidebars on your theme, so there is very little work to do here
array(
'id' => 'spyr_demo_sidebar_select',
'label' => __( 'Sidebar Select', 'text-domain' ),
'desc' => __( 'Your description', 'text-domain' ),
'type' => 'sidebar-select',
'section' => 'your_section',
)
// Get the ID value saved on Theme Options Page
$spyr_demo_sidebar_select = ot_get_option( 'spyr_demo_sidebar_select' );
// Get the ID value saved for a Page, Post or CPT ( Within the loop )
$spyr_demo_sidebar_select = get_post_meta( $post->ID, 'spyr_demo_sidebar_select', true );
// Call the sidebar
dynamic_sidebar( $spyr_demo_sidebar_select );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment