Support » Fixing WordPress » gutenberg – Is it possible to programmatically remove a block?

  • Resolved Insomnia88

    (@insomnia88)


    I want to remove/delete a block I added in the Editor programmatically (the same thing that happens when I click on the dots-menu and select “remove block” or press shift+alt+z). I don’t ask here how to remove blocks from the list of available blocks.
    Since I have the clientid and can change all kinds of different stuff there should be a way to remove it but I can’t find anything towards that.

    • This topic was modified 8 months ago by Insomnia88. Reason: typo
Viewing 2 replies - 1 through 2 (of 2 total)
  • anant101289

    (@anant101289)

    Hello,
    Please try to this code in your functions.php file.

    // disable for posts
    add_filter(‘use_block_editor_for_post’, ‘__return_false’, 10);

    // disable for post types
    add_filter(‘use_block_editor_for_post_type’, ‘__return_false’, 10);

    Insomnia88

    (@insomnia88)

    Okay but why? This seems kinda off topic.
    But I solved this on my own. What I was looking for was the removeBlocks(clientid) function

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘gutenberg – Is it possible to programmatically remove a block?’ is closed to new replies.