Gutenberg LinkControl suggestionsQuery not working

However, typing into the search input shows all post types (I want it to just show pages). That’s most likely because your code, as well as the example in the documentation, used the wrong property name — suggestionQuery — which should actually be suggestionsQuery (note the plural “suggestions”). So try using suggestionsQuery? <LinkControl suggestionsQuery={ { … Read more

Testing custom themes / plugins under Gutenberg

You don’t need the nightly build unless you’re looking for deeper core compatibility issues. For strict Gutenberg compatibility, the plugin itself should be sufficient as long as you keep it updated. You can do the nightlies on a fresh install if you wish, but it’s unnecessary overkill IMO. I would (and do) unit testing with … Read more

How to check if current admin page is Gutenberg editor? [duplicate]

In 5.0 new function was introduced (docs): WP_Screen::is_block_editor( bool $set = null ) which sets or returns whether the block editor is loading on the current screen. So you can do that check using this code: global $current_screen; $current_screen = get_current_screen(); if ( method_exists($current_screen, ‘is_block_editor’) && $current_screen->is_block_editor() ) { // DO SOMETHING } You can also add to this … Read more

How to Disable Gutenberg & Return to the Classic WordPress Editor Without any Plugins

Simply add the following to functions.php file of your current theme. <?php /** * Disable Gutenberg for supported posts. */ add_filter( ‘use_block_editor_for_post_type’, ‘__return_false’, 100 ); /** * Disable Gutenberg action and filter hooks. */ function df_disable_gutenberg_hooks() { remove_action( ‘admin_menu’, ‘gutenberg_menu’ ); remove_action( ‘admin_init’, ‘gutenberg_redirect_demo’ ); remove_filter( ‘wp_refresh_nonces’, ‘gutenberg_add_rest_nonce_to_heartbeat_response_headers’ ); remove_filter( ‘get_edit_post_link’, ‘gutenberg_revisions_link_to_editor’ ); remove_filter( ‘wp_prepare_revision_for_js’, … Read more

Gutenberg: Restrict Top Level Blocks, But Not Child Blocks

The short answer is you can’t. But you can accomplish this by using a block template that only contains your block and is locked. If your block has an InnerBlocks instance, you can add any of the registered blocks to it. add_action( ‘init’, ‘insert_template’ ); function insert_template() { $post_type_object = get_post_type_object( ‘post’ ); $post_type_object->template =[ … Read more