Skip to content

Instantly share code, notes, and snippets.

@bueltge
Last active June 15, 2017 05:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bueltge/4538951 to your computer and use it in GitHub Desktop.
Save bueltge/4538951 to your computer and use it in GitHub Desktop.
Example to use the taxonomie Dropdown for Customizer, the classes are inside the project: https://github.com/bueltge/Wordpress-Theme-Customizer-Custom-Controls
<?php
/**
* @see: https://github.com/bueltge/Wordpress-Theme-Customizer-Custom-Controls
*/
add_action( 'customize_register', 'fb_customize_register' );
function fb_customize_register( $wp_customize ) {
require_once( 'class-taxonomy_dropdown_custom_control.php' );
$wp_customize->add_section(
'my_theme_blog_featured_categories', array(
'title' => __( 'Featured Categories', 'textdomain' ),
'priority' => 36,
'args' => array(), // arguments for wp_dropdown_categories function..., optional
)
);
$wp_customize->add_setting(
'featured_category_1', array(
'default' => get_option( 'default_category', '' ),
)
);
$wp_customize->add_control(
new Taxonomy_Dropdown_Custom_Control(
$wp_customize, 'featured_category_1', array(
'label' => __( 'Featured Area 1', 'textdomain' ),
'section' => 'my_theme_blog_featured_categories',
'settings' => 'featured_category_1',
)
)
);
return $wp_customize;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment