Home / Archive / Enable Block Editor For Campaigns
Duplicate Snippet

Embed Snippet on Your Site

Enable Block Editor For Campaigns

Code that will modify the way the Campaign post type is set up to so that it uses the block editor instead of the classic editor (outdated).

Code Preview
php
<?php
/**
 * The following code will modify the way the Campaign post type
 * is set up to so that it uses the block editor instead of the
 * classic editor.
 */
add_filter( 'charitable_campaign_post_type', function( $post_type_args ) {
    $post_type_args['show_in_rest'] = true;
	$post_type_args['supports'][] = 'editor';
    return $post_type_args;
} );
/**
 * This function is also needed to remove the "Extended Description" meta box
 * which would otherwise override the content in the Block Editor.
 */
add_action( 'init', function() {
	charitable()->campaign_fields()->get_field( 'post_content' )->admin_form = false;
});

Comments

Add a Comment