Snippet: WP Glossary - Enable Gutenberg Support
With this code snippet, you activate the Gutenberg Block Editor for the WP Glossary plugin.
If you want to add a glossary, encyclopedia, knowledge base, or wiki to your website, WP Glossary is the best option. Unfortunately, until now the Block Editor is not supported. That’s why I prepared this snippet for you.
Attention: Make sure to make a backup before! Smallest errors can destroy your website.
Enable Gutenberg for WP Glossary
A glossary also deserves an appealing design and elements. With the legacy editor of WordPress, this becomes difficult. That’s why we need the block editor for WP Glossary as well.
Use the following code to enable Gutenberg for WP Glossary plugin.
The Code
<?php
// Add support for Gutenberg
add_filter ( 'wpg_post_type_glossary_args', 'bp_wpg_post_editor' );
function bp_wpg_post_editor ( $args ) {
$args['show_in_rest'] = true; // for Gutenberg Editor
return $args;
}
// Add support for taxomonies in Gutenberg
add_filter ( 'register_taxonomy_args', 'bp_taxonomy_args', 10, 2 );
function bp_taxonomy_args( $args, $taxonomy_name ) {
if ( 'glossary_cat' === $taxonomy_name ) {
$args['show_in_rest'] = true;
}
if ( 'glossary_tag' === $taxonomy_name ) {
$args['show_in_rest'] = true;
}
return $args;
}
The code snippet briefly explained:
bp_wpg_post_editor
: Enables the Gutenberg block editor for WP Glossary.bp_taxonomy_args
: Also enables category and tag boxes for Gutenberg.
Alternative downloads of the code:
Use a snippet plugin
The easiest way to insert the code snippet from above is to use one of the following plugins:
Paste into the functions.php file
If you’ve been using WordPress for a while, you may prefer to manage your snippets in the functions.php
file of your child theme.
You can do this directly in WordPress under Design > Theme Editor > functions.php, or via FTP and using the text editor of your choice.
Have fun with the full support of the Gutenberg editor in the WP Glossary plugin.