How to get value of selected page template in Gutenberg editor?

I slightly modified SkyShab’s code, because it fired template change event on page load and it didn’t fire when template was changed to default (since getEditedPostAttribute( ‘template’ ) is then ”, which equals to null when testing for template change) const { select, subscribe } = wp.data; class PageTemplateSwitcher { constructor() { this.template = null; … Read more

JavaScript in WordPress Customizer

This is because you are using wp_kses_post to sanitize the output data, try without it: <?php echo get_theme_mod( ‘script-code’); ?> also remove it from here: $wp_customize->add_setting ( ‘script-code’, array ( ‘default’ => esc_html__( ‘Script Code’, ‘x’ ), ‘sanitize_callback’ => ” // remove wp_kses_post ) ); also make sure you are using the right name of … Read more

Gutenberg block “This block appears to have been modified externally” on save

You are getting this error because your edit and save function output doesn’t match. save({attributes}) { return ( <button class=”usa-button”> { attributes.text } </button> ); } precisely, { attributes.text } is the save function is not being called or used in edit function. Either add attributes.text in edit function or remove that from save function. … Read more

Contact Form 7 – Give each checkbox a class?

with jquery in footer.php jQuery(document).ready(function($){ $(‘.wpcft-form-control div.checkbox’).addClass(‘col-4’); } or via css (you will have to adjust for various screen resolution and make some test) <style> .wpcft-form-control div.checkbox{width:33%;max-width:33%;float:left} </style> But I think you can create separate n separate checkboxes and wrap them in a <div class=”col-4″>[checkbox checkbox-x “option1″]</div> <div class=”col-4”>[checkbox checkbox-x “option2″]</div> <div class=”col-4”>[checkbox checkbox-x “option3”]</div> … Read more