Skip to content

Instantly share code, notes, and snippets.

@yojance
Created July 20, 2014 01:49
Show Gist options
  • Save yojance/7ff579c054dd15a0aead to your computer and use it in GitHub Desktop.
Save yojance/7ff579c054dd15a0aead to your computer and use it in GitHub Desktop.
OptionTree Tag Select Option Type
// OptionTree Tag Select Option Type
// Example code when being used as a Metabox or
// Exported OptionTree file to be used in Theme Mode
array(
'id' => 'spyr_demo_tag_select',
'label' => __( 'Tag Select', 'text-domain' ),
'desc' => __( 'Your description', 'text-domain' ),
'type' => 'tag-select',
'section' => 'your_section',
)
// Get the ID value saved on Theme Options Page
$spyr_demo_tag_select = ot_get_option( 'spyr_demo_tag_select' );
// Get the ID value saved for a Page, Post or CPT ( Within the loop )
$spyr_demo_tag_select = get_post_meta( $post->ID, 'spyr_demo_tag_select', true );
// Get the Tag's name
$tag = get_term_by( 'id', $spyr_demo_tag_select, 'post_tag', OBJECT, '' );
$name = $tag->name;
// Get the Archive link for this tag
$link = get_tag_link( $spyr_demo_tag_select );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment