how to edit a different page by using WP Customizer not only home page
Question
I’m working with Customizer’s it’s really powerful. I’d like to extend it, so instead of editing only the main page, I want to allow editing of inner pages.
Does anybody have the solution?
Below code to show drop-down pages. when I select any page it refreshes but doesn’t load the page.
$wp_customize->add_setting( 'themeslug_dropdownpages_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_dropdown_pages',
) );
$wp_customize->add_control( 'themeslug_dropdownpages_setting_id', array(
'type' => 'dropdown-pages',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Dropdown Pages' ),
'description' => __( 'This is a custom dropdown pages option.' ),
) );
function themeslug_sanitize_dropdown_pages( $page_id, $setting ) {
// Ensure $input is an absolute integer.
$page_id = absint( $page_id );
// If $page_id is an ID of a published page, return it; otherwise, return the default.
return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default );
}
Thanks
0
2 years
2020-12-23T10:11:18-05:00
2020-12-23T10:11:18-05:00 0 Answers
10 views
0
Leave an answer