• Resolved Guido

    (@guido07111975)


    Hi,

    I would like to use the theme on a ClassicPress website, so wondering if there’s a way to disable all block related features?

    Guido

Viewing 5 replies - 1 through 5 (of 5 total)
  • Alvind

    (@alvindcaesar)

    Hi there

    Can you clarify what you mean by block-related features? GeneratePress is a classic theme and does not include custom blocks.

    Thread Starter Guido

    (@guido07111975)

    Hi Alvind,

    My goal is GP without any block related code. Guess theme is registering block related scripts to (fully) support blocks? Is there a function that I can use to disable them? Or should I use native WP functions for that?

    Guido

    Alvind

    (@alvindcaesar)

    Okay, this snippet is probably what you need:

    /**
    * Remove GeneratePress block editor features.
    *
    * Add this code to your child theme's functions.php
    * or use a code snippets plugin.
    */
    add_action( 'after_setup_theme', 'my_child_remove_gp_block_editor_features', 15 );

    function my_child_remove_gp_block_editor_features() {
    // Remove theme support for block editor visual features
    remove_theme_support( 'align-wide' );
    remove_theme_support( 'responsive-embeds' );
    remove_theme_support( 'editor-color-palette' );

    // This should prevent the theme's block-editor.css from being loaded
    // as it's typically added via add_editor_style() after 'editor-styles' support.
    remove_theme_support( 'editor-styles' );
    }

    /**
    * Dequeue GeneratePress block editor specific CSS.
    *
    * This is an additional measure in case remove_theme_support('editor-styles')
    * isn't sufficient or if styles are enqueued differently for the editor.
    */
    add_action( 'enqueue_block_editor_assets', 'my_child_dequeue_gp_block_editor_styles', 20 );

    function my_child_dequeue_gp_block_editor_styles() {
    // Attempt to dequeue the specific block editor stylesheet.
    // The handle 'generate-block-editor-styles' is a common convention,
    // but you might need to find the exact handle if this doesn't work.
    // GeneratePress uses 'generate-block-editor-styles' for its block-editor.css.
    wp_dequeue_style( 'generate-block-editor-styles' );
    wp_deregister_style( 'generate-block-editor-styles' );
    }
    Thread Starter Guido

    (@guido07111975)

    Ah, great, I can certainly use that.

    Guido

    Alvind

    (@alvindcaesar)

    Glad to hear that!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Disable all block features’ is closed to new replies.