Questions tagged [block-editor]

The Block Editor is the 'new publishing experience' slated for introduction in WordPress 5.0, replacing TinyMCE and other aspects of the default editing experience. Find out more at https://wordpress.org/gutenberg/

Filter by
Sorted by
Tagged with
13
votes
2answers
18k views

How to add a custom CSS class to core blocks in Gutenberg editor?

I'm trying to add a class to list blocks (core/list) in Gutenberg. Unfortunately, it looks like because some blocks like lists and paragraphs don't have the standard default class name of wp-block-{...
15
votes
8answers
9k views

check if Gutenberg is currently in use

How can I check if the editor that is currently being used is Gutenberg in a WordPress plugin? I need this because Gutenberg lacks post_submitbox_misc_actions, so I need a fallback which will only be ...
3
votes
1answer
5k views

Gutenberg extend blocks add new class name

I'm trying to add an extra class name to all the blocks by extending them. Documentation: Extending Blocks I'm using blocks.BlockEdit to modify the edit component. I want to add a custom class name. ...
13
votes
2answers
2k views

Add pre-publish conditions to the block editor

The introduction of the Block Editor killed all plugins which offered publishing conditions, such as minimum word counts, featured image requirements etc. But the Block Editor did introduce the pre-...
7
votes
2answers
5k views

Validation error: Extending Gutenberg gallery block

I am trying to extend the Gutenberg core/gallery block to add some new functionality to my image gallery on the frontend. I have created a separate plugin to handle this task. I have registered my ...
7
votes
2answers
5k views

get_post_gallery with Gutenberg

I have a site where I created a page that takes the gallery images from a post and puts them into a slider. I used the following code: // gets the gallery info $gallery = get_post_gallery( $post-&...
7
votes
4answers
7k views

Gutenberg disallow certain custom blocks but keep all core blocks?

I'm writing a function to allow only some custom blocks - essentially I want to register all the blocks, then based on a database table of 'selected' blocks disallow any other custom block. I can ...
17
votes
3answers
6k views

Load CSS/Javascript in frontend conditionally if block is used

Assuming I have no infinite scroll or anything else going on in my theme: Is there a way to enqueue my custom Gutenberg block styles and scripts so they are only (lazy) loaded in the front-end when ...
10
votes
4answers
6k views

Removing panels (meta boxes) in the Block Editor

When the Block Editor was added to WordPress, custom and core meta boxes became legacy, meaning, using the remove_meta_box() function won't work when removing meta boxes/panels displayed on the post ...
10
votes
2answers
9k views

How would I get a taxonomy/category list inside a Gutenberg block?

I would like to display a dropdown list of categories (or other taxonomy) inside of a Gutenberg block. I can only think of two ways to do this: Create an array of the taxonomy in php and use ...
5
votes
3answers
7k views

Add metabox to document tab in gutenberg

How can I add custom metabox in document tab in gutenberg? There is documentation about adding plugin sidebar here, but I'm looking for adding custom metabox in existing document tab.
4
votes
2answers
1k views

Changing text within the Block Editor

Question: how can I change text within the Block Editor itself? When a user with edit but not publish permissions makes changes to a published post and clicks "submit for review," the Block Editor ...
2
votes
1answer
3k views

How to use “getEntityRecords” for user data?

How can I use getEntityRecords for user data? I have read these two posts, and it seems like that an endpoint for user is not included as the default entry for getEntityRecords in Gutenberg's source ...
12
votes
4answers
10k views

Trigger Javascript on Gutenberg (Block Editor) Save

So I have a metabox which I want to trigger some Javascript when a post is saved (to refresh the page in this use case.) In Classic Editor, this can be done via a simple redirect hooked to save_post ...
8
votes
2answers
4k views

Gutenberg add a custom metabox to default blocks

Is it possible to add custom meta boxes to the default blocks in Gutenberg? I would need to add a user-defined data-attribute to each block. This data-attribute then would be printed on the frontend ...
3
votes
1answer
3k views

Gutenberg: Get All Attributes From «core/image» Block

For design/functionality reasons, I would like to change the output of the core/image block on the frontend. I know could do it like this, but it a little bit heavy: PHP: // add my own render ...
5
votes
2answers
3k views

How to serialize a Gutenberg block from block attributes in PHP?

I am writing a migration script which has to read the post_content of posts and then dynamically change some attributes of some custom Gutenberg blocks. I was able to read the post_content and then ...
8
votes
2answers
3k views

How to use wp.hooks.addAction() in React JS/Gutenberg?

I am able to successfully use wp.hooks.applyFilters() and wp.hooks.addFilter(), but I'm not able to render a React Component using wp.hooks.addAction(). However, the console.log() runs just fine ...
4
votes
1answer
1k views

Adding pre-publish checks with Gutenberg

Before publishing an unpublished article pre-publish checks are shown. How can I extend this programmatically, and disable the publish button if the checks are not passed?
1
vote
1answer
498 views

Where on Github, or elsewhere, can I find the code for core-blocks?

Apparently, at one time, there was a directory of core-blocks for building Gutenberg templates on GitHub, but I'm not finding it anywhere. I talking about core/paragraph, etc. array( 'core/...
0
votes
1answer
3k views

Uncaught TypeError: wp.apiFetch is not a function

I'm working with the latest Gutenberg and WP and until last week, the code below worked as expected. const postSelections = []; const allPosts = wp.apiFetch({path: "/wp/v2/featured-post"}).then(fps =...
0
votes
2answers
2k views

Create Element From Dynamic HTML String [closed]

I'm working on a custom gutenberg block, and in the save method, I have dynamically changing HTML in the form of a string. element.createElement( 'div', null, contentString, ) The above ...
1
vote
3answers
6k views

WordPress v5.0.3 Gutenberg & JS error "Uncaught SyntaxError: missing ) after argument list"

After update from WP 5.0.2 to 5.0.3 I had issues in wp-admin. I couldn't edit post data. There was JS error "Uncaught SyntaxError: missing ) after argument list", undefined "_" (lodash) etc.
0
votes
1answer
179 views

Find all the places where a block type is used

I have a plugin installed that adds additional custom block types that can be used in the Gutenberg editor (the plugin is called Block Lab). Now I want to remove that plugin. For that, I have to ...
0
votes
1answer
653 views

Enhancing Gutenberg featured image control

I'm wanting to add some functionality to the featured image block in the Gutenberg editor. There are a handful of posts online about how to do this, including a question/answer here on StackExchange (...
16
votes
2answers
14k views

How to extend the gallery block in Gutenberg?

I'm playing with Gutenberg ahead of its inclusion in core, and I'd like to know how to extend the existing gallery block to change its display. For example, instead of a grid of thumbnails I'd like to ...
28
votes
3answers
25k views

Check what Gutenberg blocks are in post_content

I'm working on a design that has different styling if a certain Gutenberg block is present on a page. In other words, if the first block is a custom built Gutenberg block, the post_title is rendered ...
11
votes
3answers
4k views

Set default image link target in Gutenberg image block

I want to set the default target of the image block in Gutenberg to "Media File": I've found solutions for the classic editor, and one that appears to work for Gutenberg galleries by editing the ...
9
votes
7answers
11k views

Are there Gutenberg container blocks?

In web design, a key design element is the container that may contain various other content and blocks and is styled in CSS. Is there a Gutenberg container block that may contain other blocks? If so,...
6
votes
1answer
7k views

How do I get the current post ID within a Gutenberg/Block Editor block?

I would like to access the current post ID from within a block. According to this documentation page, it seems like I should be able to get the post ID with: wp.data.getCurrentPostId(); // or wp....
4
votes
4answers
4k views

How to disable Gutenberg editor?

As the 5.0 is getting real, and so is Gutenberg... Is it possible to disable Gutenberg and use previous TinyMCE editor? How to do this?
1
vote
1answer
2k views

Get post from custom REST endpoint in Gutenberg

I'd like to get a post object from a custom REST endpoint within a Gutenberg block. The REST endpoint returns as part of its JSON payload an array with a "post" key which contains the contents of the ...
8
votes
2answers
3k views

How to remove the core embed blocks in WordPress 5.6?

Following up on this question, I want to remove some of the default (core) embed blocks in the WordPress block editor. As of WordPress 5.6, the blocks are no longer available under the core-embed/* ...
7
votes
2answers
9k views

What are all the query parameters for getEntityRecords?

I'm working on a plugin that defined a custom block for the Gutenberg/Block Editor. The block shows a select box of posts. When you select one, I create HTML with some of the selected post's fields, ...
5
votes
2answers
2k views

Set Post Title to Read-only and Disable Permalink Slug Editor in Gutenberg

When using Gutenberg I would like to disable all users except administrator from being able to edit a post's title even though I want to allow them to edit the post, and I would like to disable the ...
9
votes
2answers
6k views

WordPress adding scaled images that don't exist (1536x1536 and 2048x2048)

I'm building a theme in _S and using native Gutenberg blocks. I have the following code via my functions.php file to set my image sizes: add_theme_support( 'post-thumbnails' ); add_image_size( '...
4
votes
3answers
5k views

Implement Panel Color Inspector Control in Gutenberg

I am trying to implement Panel Color in the Inspector Control for a custom block but can't seem to figure it out. Below is the JSX code that attempts it. It renders the block, but when it's in focus, ...
4
votes
1answer
1k views

Remove border radius setting from the Gutenberg button block?

I want to remove the border radius settings from button block so users can't access it since I don't want them getting confused on why it's "not working" (I forced 0 radius in the css for ...
4
votes
2answers
5k views

Add Formatting Buttons to Gutenberg core/paragraph BlockControls

When inserting a core/paragraph block to the content, we can choose e.g. "bold", "add link" from the controls above the content: For my customer, I would like to add formatting buttons for <sup>...
4
votes
2answers
3k views

How to filter by custom post type on Gutenberg "Latest Posts' block

When adding the "Latest Posts" block within Gutenberg, is it possible to filter by custom post type? Here are the options I can see: Would I need to create a custom block for this type of ...
3
votes
1answer
3k views

File structure and react setup when creating multiple Gutenberg blocks

I'm having trouble understanding the build/compile setup and file structure when creating multiple blocks in Gutenberg. Both React and Gutenberg are new to me. But I've had a pretty good primer on ...
2
votes
1answer
1k views

Can you filter posts by meta key with the getEntitityRecords selector?

As my first foray into WP5-era theme development I am trying to develop blocks to replace where I would normally use shortcodes and a metabox plugin. After a lot of learning I have finally managed to ...
2
votes
1answer
420 views

What do the args for Gutenberg subpackage "hooks" function "doAction" mean?

The package is supposed to mime WP's own actions system: https://github.com/WordPress/gutenberg/tree/master/packages/hooks I've installed it locally and loaded up all of its modules, unfortunately, ...
1
vote
1answer
217 views

Choosing a default page tempate (Classic => Gutenberg)

This code was working in the "Classic" era to set a default page template: /* Blank Page by default */ add_action('add_meta_boxes', 'blank_default_page_template', 1); function ...
0
votes
2answers
2k views

Using Gutenberg block components in admin interface controls

I asked a previous question, and got a helpful answer that got me going quite a ways. The present problem is unrelated, but IMO reflects the dearth of documentation suitable for those of us who aren't ...
5
votes
2answers
4k views

Is it possible to use Gutenberg on the front-end?

Now that WordPress 5 has the new Gutenberg editor, I'm interested in the possibility of using it programmatically on the front-end (for example as as a rich-text editor for bbPress). In the past I've ...
4
votes
3answers
2k views

What version of Gutenberg is included with WordPress?

Gutenberg is developed separately https://github.com/WordPress/gutenberg and the latest version currently is 7.2.0. How to find out which version of Gutenberg is included in my WordPress installation?...
4
votes
2answers
1k views

Style new block-editor alignfull class without scrollbars or overflow

With WP 5.0 you can now enable full width blocks in the editor by adding this to your theme: add_theme_support( 'align-wide' ); However, if you are using a custom theme you have to add your own CSS ...
3
votes
2answers
6k views

Add classname to Gutenberg block wrapper in the editor?

I'm trying to create custom columns block in Gutenberg. Is it possible to add class to the wrapper of the element in the editor based on the attributes? I'd like to switch ??? to class based e.g. ...
3
votes
1answer
1k views

get selected categories or tags (using javascript) in GutenBerg?

I was still unable to find out that in Gutenberg. Specifically, i used: wp.data.select("core/editor").getPostEdits(); to find out how many categories were checked. But it missed already checked ...