[Resolved] Gutenberg (block) editor for category

Home Forums Support Gutenberg (block) editor for category

  • This topic has 6 replies, 4 voices, and was last updated 1 month ago by twarrior.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1115663
    Vijay

    I am loving the flexibility of the block editor with the layout capabilities of GeneratePress.

    However, category description is using the Classic Editor.

    WordPress Edit Category

    Wondering if it is possible to enable the block editor for such category pages as well?

    #1115670
    Leo
    Staff
    Customer Support

    Hi there,

    This isn’t the theme can do as it’s handled by WordPress.

    Looks like someone already mentioned it to WordPress:
    https://github.com/WordPress/gutenberg/issues/12511

    #1696532
    twarrior

    How you get to show the Classic Editor in the category description?

    #1696586
    Ying
    Staff
    Customer Support

    I think you will need some kind of plugin to give the flexibility to edit category descriptions πŸ™‚

    #1696665
    Vijay

    Thanks Leo, have you seen any plugins that provide this functionality?

    @twrrior and @Ying,
    Classic editor is default for Post Categories and Tags. You don’t need a plugin for it.

    Screenshot-20210316-130103

    #1696749
    Elvin
    Staff
    Customer Support

    Hi there,

    There’s actually a way to use Block Element and its contents as for the category description but it has its drawbacks.

    First, we can allow shortcodes to run on category description field.

    We can do that by adding these PHP snippets:

    add_filter( 'term_description', 'shortcode_unautop' );
    add_filter( 'term_description', 'do_shortcode' );
    remove_filter( 'pre_term_description', 'wp_filter_kses' );

    We then create a shortcode to allow us to create portable hooks anywhere it’s placed.

    add_shortcode('portable_hook', function($atts){
    	ob_start();
            $atts = shortcode_atts( array(
                'hook_name' => 'no foo'
            ), $atts, 'portable_hook' );
    		do_action($atts['hook_name']);
    	return ob_get_clean();
    });

    Usage: [portable_hook hook_name="my_custom_hook"]

    You can use this shortcode on a category description as shown here:
    https://share.getcloudapp.com/12uoW914

    Now we can create a Block element we can hook into my_custom_hook.

    Here’s an example: https://share.getcloudapp.com/nOuljEN2

    After saving, the block element should appear as the category description.

    With this, you can name the hooks unique for each category. You can also make a block element for each category description. πŸ˜€

    I understand that this seems pretty advances and it has its drawbacks(you have to create multiple block elements) but if you want to use Gutenberg for the category description, this could work.

    A wise man once said:
    "Have you cleared your cache?"

    #1697200
    twarrior

    @Vijay

    Classic editor is default for Post Categories and Tags.

    Sorry, but in your first image there is an editor, and in the second one no.

    By default, worpress dont show any editor in the category description. Maybe you installed a plugin?

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.