A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

New answers tagged

0

I know this has been a while, but I found this page looking for the same answer. Once I discovered the solution, I thought I would share it here to help you or someone in the future. Once you convert the classic to blocks, you can multi select the images, and then the convert button allows you to convert to a gallery. I noticed mine stayed at thumbnail ...


0

I think the problem might be that the spread operator is missing in a couple of places. This line: return { meta: { currentMeta, editedMeta }, }; in withSelect should be: return { meta: { ...currentMeta, ...editedMeta }, }; This makes the meta object be a copy of currentMeta (have all the same properties and values), but overwrites them with ...


-1

You could create a plugin for the editor to achieve that. In JS there's the onpaste event. These would be the basic steps: listen for onpaste. Find the closest heading element up the tree from the target element being pasted into. Default to page/post title if no heading elements are found and then back to the default naming convention if all else fails. ...


0

I can reproduce this as well. Adding show_in_rest in register_taxonomy function, as suggested by many, would normally be proper answer, but not full answer in your case. This is because rest endpoint types is already in use by Wordpress itself. https://example.com/wp-json/wp/v2/types will return registered post types and therefore Gutenberg does not ...


1

First Add a normal Shortcode block and type the shortcode [foo]123[/foo] Then click More Options for the block and select Add to Reusable Blocks Then provide a name as Foo Next, time you can search and add the Foo block instead of typing the shortcode Thanks


1

The Block Editor's save() function doesn't save JS functions to the database to be run on the front end. To run JS on the front end, you need to save it as a separate file and enqueue that file explicitly on the front end. With that in mind, it would be easiest to rewrite your save() function so that instead of trying to call a function directly, it has a ...


0

If you look into the source code for getEntityRecords, you'll see that the the core/data library creates entities using the Wordpress API in entities.js. So you can use any parameter available in the REST API. Here are options for posts: context page per_page search after author author_exclude before exclude include offset order orderby slug status ...


0

The code that goes into core doesn’t necessarily reflect the exact code that is in a specific version of the Gutenberg plugin which is why it is hard to determine which version of Gutenberg is included in the core WordPress.


0

You can load the css via PHP instead , add_action('wpmm_head', 'wpmm_custom_css'); function wpmm_custom_css(){ echo '<style> #intro{ '.get_template_directory_uri().'/assets/main.png; } </style>'; }


0

add code in your functions.php add_action('wp_head', 'hook_in_frontend_head'); function hook_in_frontend_head() { $screen = get_current_screen(); if($screen->id == 'your-blog-page-id') { ?> <style> your additionl styles here</style> <?php } }


2

Depending on your goal, you can add custom CSS for blocks in several ways. Theme Adding it "themewide" by either using a theme's Custom CSS area or creating a child theme could be used either to affect all copies of a particular type of block, or to target one type of block on just a single post. For example, each URL of a WP site should have a <body>...


0

I found this tutorial, How to Add a Button to The Gutenberg Editor, and its example on Github.


0

You might also like to take a look at the REST API endpoint that handles block rendering for ServerSideRender. If I understand correctly from your followup post in WP Slack (registration required) you want to pass down a post ID as a block attribute. In that case you need to be sure that you have a matching attribute for "post ID" registered for the block-...


1

You can add a 2 column block layout where 1 block takes up 2 thirds in the block editor using the UI. Adding CSS classes to achieve this is highly unusual and unnecessary When you add a column block it asks you: Resulting in column blocks spaced for thirds: Each block has a percentage width in the block settings: If you wanted to use the CSS classes from ...


1

The js-file is not executed on time By the time the DOM load event is executed the block editor has already parsed the post content and at that time the block wasn't yet registered so it tells you that it doesn't exist. Instead of: window.addEventListener( 'load', () => { mcm_register_menu_card_section_block(); }); try: wp.domReady(...


1

First thing that jumps out is that in: <!-- wp:mvc/block-mvc-offer-details {"data_offer":"2426"} /--> the data_offer value is stored as a string while it's defined attribute type is number. This could be why it's stripped after reload. While select('core').getEntityRecords does return IDs as integers it's possible that after passing that data to <...


0

I managed to come up with a solution myself. To get a list of posts of a specific post type one must wrap the wp.data.select( 'core' ).getEntityRecords() selector inside the withSelect higher order component, which is a function that provides props to a component using selectors. Then, we can populate a SelectControl with this data. export const settings = {...


1

OK, I found a way to do this after browsing the source code. I do note that the code that helped me lives under deprecated.js so it's possible this won't continue to work. Here's the JS code I have in my plugin directory function addAlignmentToGroups(settings, name) { if (name !== "core/group") { return settings; } return lodash.assign(...


0

If you are working on a Wordpress Theme you can use the function: get_template_part( string $slug, string $name = null ) Wich loads a template part into a php template. get_template_part() will do a PHP require() for the first file that exists... So effectively it will work as if you were requiring another php file. For example, in your case, you can ...


0

You can simple use wp data api to get the default class name of your block like this: const className = getBlockDefaultClassName("namespace/yourblockname"); getBlockDefaultClassName is from wp.blocks so you can import it: import { getBlockDefaultClassName } from "@wordpress/blocks"; or const { getBlockDefaultClassName } = wp.blocks; Hope it helps!


1

As of now, there is no dedicated user capability to read a reusable block; it is not possible to customize the capabilities (reading, editing, deleting) reusable blocks for users. The capabilities are currently tied into in the capabilities of the post type post.


Top 50 recent answers are included