custom field – changing an element or background of id div – different versions not working

In most themes anything added via the wp_head hook should appear after (and override) enqueued CSS. So you could add an action to the themes functions.php and use get_queried_object_id() for the post ID. function my_dynamic_css() { $custombg = get_post_meta( get_queried_object_id(), ‘custombg’, true ); if (! empty($custombg)) { ?><style>#Box2 {background: <?php echo $custombg; ?> }</style> <?php … Read more

Ajax wordpress function showing source code in alert and not value of input field?

Move the AJAX handler function hook outside of init callback and hook your script registrations to wp_enqueue_scripts. And, the hook to attach the handler callback would be wp_ajax_nopriv_postcode_ajax2. function ajax_postcode_form_init() { wp_register_script(‘ajax-login-script’, get_bloginfo(‘stylesheet_directory’). ‘/ajax-postcode-script.js’, array(‘jquery’) ); wp_localize_script( ‘ajax-login-script’, ‘ajax_login_object’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ), )); wp_enqueue_script(‘ajax-login-script’); } add_action(‘wp_enqueue_scripts’, ‘ajax_postcode_form_init’); function postcode_ajax2() { $postcode = … Read more

How do I add a class to Customizer preview based on class of Customizer control? (Customizer Javascript API)

Consider again how you want the control to work. If you hide the control, how would you unhide it? It sounds like you want a checkbox, to indicate whether the section is displayed or hidden. In your PHP on the ‘customize_register’ action, you define the holder of the indicator. They’ve named this a setting, with … Read more