Skip to main content

Questions tagged [react]

The tag has no usage guidance.

28 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2 votes
0 answers
25 views

Using @wordpress/scripts 28.x with WordPress <6.5

I am currently looking for a way to use the current @wordpress/scripts 28.x in a plugin with WordPress 6.5 or older. According to the tip here, you should deliver the jsx-runtime via webpack, but ...
Thomas Zwirner's user avatar
2 votes
0 answers
43 views

configure additonal build files in the @wordpress/create-block

I'm using the @wordpress/create-block package to create my block plugin. It comes with preconfigured webpack settings to build all the assets. By default as js in the src/ folder is built in the build/...
Will Honeywill's user avatar
2 votes
0 answers
146 views

How to add more elements to an already existing <PanelBody> section in Gutenberg

I am filtering core blocks to add more functionality and I know how I can create a new section in the sidebar that is opened by default like this: return ( <> ...
NextGenThemes's user avatar
1 vote
0 answers
28 views

Extend WordPress Gutenberg core/navigation-link

Hey folks So Im pretty new to this react + php in wordpress and I found one article where it showed how to extend a core block, which works fine for group and some basic block but When i tried to ...
DevopsRedefined's user avatar
1 vote
0 answers
30 views

Remove AM/PM in gutenberg add/edit post and use 24-h format

How can I setup 24-hour format, and still keep the english language in wordpress. (tried us, australian, uk, south africa) See screenshot. I tried everything, found this url, but it does not tell me ...
Raf A.'s user avatar
  • 11
1 vote
0 answers
63 views

Core/Image access caption in render_template and in wp.hooks

I am making an override to core/image block -disabling styles, changing markup and such. I have managed to solve some things, but struggle with some others. Here is my code: filters.php <?php use ...
Sam Tyurenkov's user avatar
1 vote
0 answers
89 views

Custom plugin translation not working

I made a plugin that contains 2 custom gutenberg blocks created with react and jQuery (for some front-end stuff) and I'm having troubles translating them. There are no translation strings inside the ...
tsvetko.krastev's user avatar
0 votes
0 answers
24 views

Gutenberg Dev - React Context.Provider returns undefined

I have a Context.Provider with a value setup in slider/edit.js. When I import it in the child component slide/edit.js with useContext it returns undefined I don't see what I'm missing here For context ...
Grzes Slania's user avatar
0 votes
0 answers
9 views

Event when Modal is opened/visible

In my WordPress plugin, a Modal gets opened from within the Block Editor when a button is clicked. const MyContent = () => { const [isOpen, setOpen] = useState(false); const openModal = () =...
Abid's user avatar
  • 153
0 votes
0 answers
66 views

Implementation of React-Datepicker component with Gutenberg in Wordpress

I'm working on a custom plugin that require an daterange picker control in a custom post type sidebar. Since I'd like to use Gutenberg for this (state that I'm quite a novice in React & Gutenberg ...
Paolo Sacchetti's user avatar
0 votes
1 answer
70 views

How can i extend the existing Block Inspector Tabs in Wordpress Gutenberg Editor?

With <InspectorControls> i'm able to extend the WP Gutenberg Sidebar but i want to extend the default tabs like in this picture: How can i create my own sidebar tabs?
Sam Weiss-Gamtschi's user avatar
0 votes
0 answers
18 views

Unable to trigger a frontend @wordpress/hooks action

I’m trying to implement a frontend WC block hook, but unfortunately I’m not able to trigger it. I’m using a fresh 8.7.0 install, and blocks are definitely enabled. I’ve tried following the ...
Dylan Pierce's user avatar
0 votes
0 answers
67 views

wp_add_inline_script vs wordpress fetch api

Inorder to pass some data from PHP to the javascript files, we can use either wp_add_inline_script or fetch api. Is there any condition, where each one of them is preferred over the other ? I have ...
Shadow's user avatar
  • 57
0 votes
0 answers
21 views

Force post update with React

I'm creating a plugin and I have added a custom settings panel in the editor sidebar. In my settings panel I have a couple of text inputs and a custom button that calls an endpoint to pass some data ...
TsvetkoKrastev's user avatar
0 votes
0 answers
15 views

How to add a react element into the DOM node (only on the user-interaction like on click) without using the state?

I'm working on a WP plugin project that requires a react element to take the position of the main DOM node(main component) content when the button is clicked, but without the use of state in the main ...
Shashikant Yadav - Kantbtrue's user avatar
0 votes
0 answers
39 views

Separate typography controls for titles and meta in a custom block?

I'm building a simple dynamic custom block that shows a list of posts of a custom post type. JS: import metadata from './block.json'; import './style.scss'; const { name } = metadata; export const ...
leemon's user avatar
  • 1,950
0 votes
0 answers
177 views

Embedded data and the _fields parameter in getEntityRecords

I'm using the following code to retrieve a list of post of a custom post type named movie: const { posts, hasPostsResolved } = useSelect(select => { const query = { order: 'desc', ...
leemon's user avatar
  • 1,950
0 votes
1 answer
45 views

Image size not showing up in 'wp/v2/media'

I'm trying to get the URL of a specific image size, and I'm using apiFetch: const response = await apiFetch({ path: `wp/v2/media/${id}`, method: "GET", }); The ...
Vincent's user avatar
0 votes
0 answers
180 views

Get realtime title and featured image value in Wordpress block

I'm building a WordPress block in React, and I need the title and featured image to be displayed in the block. So I need a way to get the title value and the featured img URL in real time, so it ...
Michael's user avatar
0 votes
0 answers
975 views

Gutenberg block: add a multi-select for posts

I created a custom Gutenberg block with @wordpress/create-block. I now have a dropdown where you can select a post, but I would like this to be a multi-select where you can select multiple posts. How ...
azrac's user avatar
  • 1
0 votes
0 answers
114 views

Force-update the meta variable first set using `var [ meta, setMeta = useEntityProp( 'postType', postType, 'meta' );`

Context: I've got a plugin that triggers some actions when a post is saved, like contact an external API and save the result as a custom field. All of this happens in the background, using PHP and the ...
Jan Boddez's user avatar
0 votes
0 answers
28 views

How to access WP header from Appearance > Header using WP Rest api (React)

Need to use the WordPress Header Section in react js. No plugin is used for plugin it is by default.
Anand Kumar's user avatar
0 votes
0 answers
252 views

WP Rest-API response is unauthorized (React)

I am using trying to fetch data from wp to react via rest api. There are two API's I am working upon. First one is wp/v2/pages is working fine (With credentials it is authorized) but, Second api wp/v2/...
Anand Kumar's user avatar
0 votes
0 answers
102 views

Cannot call a class as a function in block plugin react component

I'm developing a block plugin and working with the React packages for WordPress. In my Save function I'm trying to load a slider component from the package ['react-slick'] (https://github.com/akiran/...
Will Honeywill's user avatar
0 votes
1 answer
2k views

How can I include React useState in a custom gutenberg block plugin?

The block code is as such: wp.blocks.registerBlockType('myblocks/gallery', { title: 'Gallery', icon: 'my-gallery', category: 'common', attributes: { }, edit: props => { const [...
budgiebeaks's user avatar
0 votes
0 answers
124 views

How do i fix type error

i an getting an error in my react build online, even though it seems to be working fine locally. react-dom.production.min.js:189 TypeError: Cannot read properties of undefined (reading 'length') at VK ...
Mad Crowe's user avatar
0 votes
2 answers
136 views

Why is my Toggle field not showing in Gutenberg?

I am adding a PluginSidebar to Gutenberg and it works until I try to add a meta field to the sidebar. Then it doesn't work. I'm not sure why though. import { registerPlugin } from "@wordpress/...
JayDev95's user avatar
  • 179
0 votes
0 answers
939 views

What is the proper way of using React Hooks in Gutenberg on frontend?

I'm mostly interested in useState. It works fine in edit.js, but in save.js it just breaks and it throws the minified React error, see below: I tried creating a separate .jsx component file but it ...
Kerox's user avatar
  • 101