Breaking
Sun. Nov 24th, 2024

Enable “Gutenburg” WordPress Editor for Custom Post Types

By admin Jun 26, 2024


Just a quick code snippet for anyone who had the same issue as me, especially anyone using the Custom Course Templates for LifterLMS plugin.

This site uses plugins that enable custom post types, but some of the plugins do not consider using the new WordPress content editor (“Gutenberg”) which is no longer new, for a weird reason that I do not know.

Here’s what to put into your code snippets plugin or Functions.php

add_filter('register_post_type_args', 'lifterlms_template', 10, 2);
function lifterlms_template($args, $post_type){
 	//print($post_type);
    if ($post_type == 'bsf-custom-template'){
        $args['show_in_rest'] = true;
    }
 
    return $args;
}

The code above looks for the specific custom post type I am interested in called “bsf-custom-template” but of course substitute that for the name of the one you are dealing with.

Boom, now you can use the blocks and patterns that you are used to!

(I also submitted a pull request to the developer of that particular plugin, they just need to enable the show_in_rest option when they register the CPT)



Source link

By admin

Related Post