Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wpsunshine
wpsunshine / wordpress-show-block-in-theme.php
Created May 13, 2021 17:40
Display block in theme template files
$block = get_post( 123 ); // Change 123 to the unique post ID for your block
echo apply_filters( 'the_content', $block->post_content );
@wpsunshine
wpsunshine / gf-enhanced-ui-list-select.js
Last active March 28, 2024 17:03
Gravity Forms use enhanced UI on select drop down for lists
<script>
// For standard forms
jQuery( document ).on( 'gform_post_render', function( event, form_id, current_page ){
gformInitChosenFields( '#field_12_10 select', 'No results matched' ); // Change selector to #field_FORMID_FIELDID
});
// Forms that use multiple pages and ajax
jQuery( document ).on( 'gform_page_loaded', function( event, form_id, current_page ){
gformInitChosenFields( '#field_12_10 select', 'No results matched' ); // Change selector to #field_FORMID_FIELDID
});
</script>
@wpsunshine
wpsunshine / gf-body-class-after-submission.php
Created April 1, 2021 21:12
Gravity Forms add body class after submission
add_action( 'gform_after_submission', 'wpsunshine_gf_after_submission', 10, 2 );
function wpsunshine_gf_after_submission( $entry, $form ) {
add_filter( 'body_class', function( $classes ) {
return array_merge( $classes, array( 'gf-submitted' ) );
} );
}