Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gagimilicevic/13d1098df3ac8e6f0da173f9331ae70c to your computer and use it in GitHub Desktop.
Save gagimilicevic/13d1098df3ac8e6f0da173f9331ae70c 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