Javascript for a specific wordpress page
You can use wp_enqueue_scripts hook to load js file. Once you load the js file successfully, then the issue will not regarding WP.
You can use wp_enqueue_scripts hook to load js file. Once you load the js file successfully, then the issue will not regarding WP.
You can get the comments by checking: https://site/wp-json/wp/v2/comments?post=150 Where post=150, is the ID of the post. I don’t really know what do you mean by likes, but there are not likes WordPressPres natively.
Custom Block – save.js function not saving attributes
I need to access the dom element inside the editor. useRef can be used for that, but actually, instead of doing that, I would just apply the approach shown below to my edit() function 🙂 https://reactjs.org/docs/faq-ajax.html So using a function component, you can achieve the same thing your front-end script does like so: Remember to … Read more
Most of the time you should not modify core by yourself – it will get overwritten after update and it may cause some conflicts. Of course, if you know what you’re doing and the vulnerability is really serious, then you can update given library and test everything by yourself. As for awareness. Most of the … Read more
When using a control that modifies a block attribute, you need to set the value of the control to the value of the attribute and the onChange function needs to change the attribute using the setAttributes function: el( RangeControl, { label: ‘Columns’, value: props.attributes.my_attribute, initialPosition: 1, min: 0, max: 3, onChange: function( val ) { … Read more
In WP jQuery works in compatibility mode by default. It means that the typical $ shortcut for jQuery doesn’t work, so it doesn’t conflict with any other JavaScript libraries that use the dollar sign also, like MooTools or Prototype. So you should use jQuery instead of $ in your JS file. Of course you can … Read more
edit: ok after working on this for the last hour ive finally found a solution that works without affecting uploading and without messing with ignore or reset wp.media.frame.on(‘open’, function() { if (wp.media.frame.content.get() !== null) { // this forces a refresh of the content wp.media.frame.content.get().collection._requery(true); // optional: reset selection wp.media.frame.content.get().options.selection.reset(); } }, this);
Turns out Gutenberg has another way of storing attribute values: the block’s comment delimiter: If no attribute source is specified, the attribute will be saved to (and read from) the block’s comment delimiter. source When I inspected the database entry, I indeed found the size attribute there: <!– wp:XXX {“size”:48} –> <div>…</div> <!– /wp:XXX –> … Read more
I can access the points using http requests to the external api, but I need to be able to access the full api inside of the react-wp-theme. You could use either the wp-api script / Backbone JavaScript client library or one of the other client libraries listed here such as the node-wpapi library. Using the … Read more