wordpress-gutenberg

How can I access the values of an inner block in Gutenberg?

☆樱花仙子☆ 提交于 2021-01-29 03:11:39
问题 I'm trying to build a custom block for Gutenberb. It is a carousel and uses child blocks (images). I'm trying to find a way to find out how many image-blocks were created inside to block so I can create slides for the carousel accordingly. In order to do that, I was thinking about taking the image url from each image block and store it in an array so then I can just map through the array to create each slide, but I have no idea how to access the url value from the child block. Any ideas? 回答1:

Update a specific property of an object attribute in a Wordpress Gutenberg block

不想你离开。 提交于 2021-01-28 02:07:58
问题 I have a custom Gutenberg block with an attribute: valuesObj: { type: 'object', default: {}, } I want to update a specific property within that object when an input is changed. So I have created a function that gets called from onChange on the component: <TextInput value={ valuesObj[index] } onChange={ (value) => this.onChangeValue(value, index) } /> This is the function that gets called: onChangeValue(value, index) { var newValuesObj = this.props.attributes.valuesObj; newValuesObj[index] =

Wordpress 5.2 YouTube video auto-embed in posts is not working

我只是一个虾纸丫 提交于 2021-01-27 17:51:52
问题 In my personal Wordpress blog (5.2), the auto-embed for videos does not work. The editor shows a spinner (very briefly), but then it shows the link to the video in the backend and the URL in plain text in the frontend instead. I've tried changing the post in different Browsers (all failed), I tried different videos - some from vimeo (none works). When I use the iframe embed-code provided by YouTube in the HTML-editor for the post the exact same video works fine in the same post. I've disabled

How to disable Gutenberg / block editor for certain post types?

北城余情 提交于 2021-01-20 15:22:12
问题 WordPress added Gutenberg / block editor in its 5th version and it's enabled by default for Post and Page post types. It might be enabled by default for all custom post types in close future so as a WordPress developer I want to know how to disable this editor for my own custom post types? I want to keep classic editor for the post types that I registered from my plugins or themes. 回答1: It's possible to simply disable the editor using a WordPress filter. WordPress 5 and Higher If you want to

How to disable Gutenberg / block editor for certain post types?

旧街凉风 提交于 2021-01-20 15:19:07
问题 WordPress added Gutenberg / block editor in its 5th version and it's enabled by default for Post and Page post types. It might be enabled by default for all custom post types in close future so as a WordPress developer I want to know how to disable this editor for my own custom post types? I want to keep classic editor for the post types that I registered from my plugins or themes. 回答1: It's possible to simply disable the editor using a WordPress filter. WordPress 5 and Higher If you want to

WordPress Gutenberg: This block contains unexpected or invalid content

北战南征 提交于 2020-08-24 06:58:24
问题 I am creating very simple text block. The block works fine when I add this for the first time. If I refresh the page and try to edit the block it show me the message "This block contains unexpected or invalid content.". I have tried to disable htmlvalidation check but that doesn't help. Also, after I click on resolve: the current block and after conversion block contain same code. http://prntscr.com/lwv18b http://prntscr.com/lwv1e1 This is my index.js file code <pre> /** * Block dependencies

How to change WP Gutenberg's category components panel?

橙三吉。 提交于 2020-02-25 08:11:05
问题 In Gutenberg Editor, I try to modify the categories panel (the one on the right where I choose the categories my post will be placed into). One should not be able to add a post to a category if that category has child-categories. As the categories are static, it'll be ok to use the category-id. My idea was to use the enqueue_block_editor_assets and add some javascript to disable the checkbox via the ID of the element. This does not work, the element could not be found :-( This is my

Gutenberg Block Validation Failed ( not expecting children )

依然范特西╮ 提交于 2020-01-04 13:59:07
问题 I am developing a gutenberg Testimonials block, however when saving and trying to reload it gives me block validation failure, it seems to be expecting a block without children in the carousel-inner etc. Expected: <div class="wp-block-wf-testimonials"><div class="slideshow carousel slide" data-ride="carousel" data-interval="false"><div class="carousel-inner"></div><a class="carousel-control carousel-control-prev" href="#undefined" role="button" data-slide="prev"><span class="carousel-icon

How can I add conditional control field in Inspector controls of Gutenberg?

风流意气都作罢 提交于 2019-12-25 03:15:27
问题 I'm developing a countdown Block for Gutenberg. I have 7 styles in the block, So I want to show/hide some control fields in the inspector control based on the style. As far I know Gutenberg didn't introduce conditional field yet. So I want to do it by custom code. Here is my full code for the inspector controls. https://pastebin.com/177BDgMQ And here is a screenshot of what i want. I'm a javascript beginner, so can't understand how can I apply a condition in t enter code here here. 回答1: I've

Wordpress gutenberg block - jquery generated content not saved

故事扮演 提交于 2019-12-25 03:13:52
问题 I am new to Wordpress Gutenberg blocks. I created a gallery plugin and I want a user to be able to insert gallery shortcode by simply choosing the desired gallery from a popup window. I use jQuery text() function to inject shortcodes from the popup window with success but the content will not be saved. However, when I type in some text everything works fine. Here is my Gutenberg js: var el = wp.element.createElement, registerBlockType = wp.blocks.registerBlockType, RichText = wp.editor