[wp-hackers] Contextual Customizer Option

Lox lox.dev at knc.nc
Thu Jul 16 23:29:17 UTC 2015


Hello,

I need some contextual options in the customizer (related to the current
post in view)
Displaying a contextual panel/section/control is straight forward, but I
have issues saving/getting the option data from post metas.

My example is as simple as providing a page template dropdown for pages
(getting the control to display isn't the issue)

<?php

function customize_save_page_template ($value) {
    return update_post_meta( get_queried_object_id(), '_wp_page_template',
$value );
}
add_action( 'customize_save_page_template', 'customize_save_page_template');

function customize_update_page_template ($value) {
    return update_post_meta( get_queried_object_id(), '_wp_page_template',
$value );
}
add_action( 'customize_update_page_template',
'customize_update_page_template');

function customize_value_page_template ($default) {
    return get_post_meta( get_queried_object_id(), '_wp_page_template',
true );
}
add_action( 'customize_value_page_template',
'customize_value_page_template');

None of those work: it seems the customizer isn't aware of the current post
ID.

Any idea ?

Regards.

-- 
Lox
lox.dev at knc.nc


More information about the wp-hackers mailing list