Skip to content

Instantly share code, notes, and snippets.

@devinsays
Last active May 26, 2017 13:55
Show Gist options
  • Save devinsays/b69da4ad3dd11cc7fc08 to your computer and use it in GitHub Desktop.
Save devinsays/b69da4ad3dd11cc7fc08 to your computer and use it in GitHub Desktop.
Page Selector in Customizer
/**
* Add page selector to the customizer.
*
* @since Theme 1.0.0
*
* @param WP_Customize_Manager $wp_customize Customizer object.
*/
function prefix_customize_register( $wp_customize ) {
$wp_customize->add_section( 'showcase' , array(
'title' => __( 'Showcase', 'textdomain' ),
'priority' => 30,
) );
for ( $count = 1; $count <= 4; $count++ ) {
// Add color scheme setting and control.
$wp_customize->add_setting( 'showcase-page-' . $count, array(
'default' => '',
'sanitize_callback' => 'absint'
) );
$wp_customize->add_control( 'showcase-page-' . $count, array(
'label' => __( 'Select Page', 'textdomain' ),
'section' => 'showcase',
'type' => 'dropdown-pages'
) );
}
}
add_action( 'customize_register', 'prefix_customize_register' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment