Insert “javascript:void(0);” into URL

I also can’t stand the fact the WordPress removes “javascript:void(0);” from my hrefs (or anything else TBH…) upon saving or using the visual editor. I just started using the Raw HTML plugin that does the job. I enclosed my code in [raw] … [/raw] codes, and did NOT use the visual editor. My “voids” remain … Read more

can a buttongroup have a label?

I have discovered a way of creating a label and a help property for a component that doesn’t have it’s own label or help properties, by wrapping that component in a BaseControl component. Here is my working solution: createElement(PanelRow, {}, createElement(BaseControl, { label: __(‘N element alignment’, ‘my-textdomain’), help: __(‘Set the alignment for n element in … Read more

event/callback on block update?

You might try a useEffect hook subscribed to the attributes.identifier to call the script. something like: function Edit( { attributes, setAttributes } ) { useEffect( () => { // this will fire whenever the attribute changes. thirdPartyScriptFunctionName(); },[attributes.identifier]) const onChangeIdentifier = (value) => { setAttributes({ identifier: value }); }; return ( <div id = {`embed-${ … Read more

Using wp.data.select get actual tags (not id’s) used in post

You can use getEntityRecord() like so: const tag_ids = wp.data.select( ‘core/editor’ ).getEditedPostAttribute( ‘tags’ ); // the last parameter is always the tag ID (and just one single ID) const tag = wp.data.select( ‘core’ ).getEntityRecord( ‘taxonomy’, ‘post_tag’, tag_ids[0] ); console.log( tag ? tag.name : ‘still resolving or no such tag..’ ); Or use getEntityRecords() with the … Read more

wp-env mysqlcheck error:1130

Step 1: Find the name of your wp-env container First, you need to locate the name of the container created by wp-env. To do this, in the directory of your project containing .wp-env.json, you must run the following command: docker ps This should give you a list of containers. In the Names column, you’ll see … Read more

Adding JavaScript to a WordPress website

Using this link, you will find helpful notes as to how to add a script to your WordPress website. The main idea is to use inbuilt WordPress functions to load your scripts. This is done via the wp_enqueue_script function. Following examples provided in the aforementioned link, you will be able to learn how to enqueue … Read more

Gutenberg add extra attributes to custom format

I was able to add the attribute by passing it in attributes through the registerFormatType settings: attributes: { ‘custom-attr’: ‘custom-attr’ }, then in edit(): toggleFormat( value, { attributes: { ‘custom-attr’: ‘Hello world’ }, } ) I don’t know how exactly it all works together because I could not find detailed explanations in the current documentation. … Read more

How to use div -ids in url to jump to specific post…Is trailing slash the culprit?

First, I’d recommend using “pretty permalinks” over the default query-string structure. This will eliminate most of your problems from the getgo. It will turn your http://www.example.com/?cat=15#post-170 urls into http://www.example.com/category/category-slug/#post-170 and the browser will move correctly to the post’s position in the page. That said … Yes, you can remove the trailing slash. The trick is … Read more

Hide reply button after moveForm is called

Ended up using jQuery to solve this. The form moves around using javascript anyways so it doesn’t break anything for users with js turned off. //when reply button is clicked hide it $(“.comment-reply-link”).click( function() { $(this).hide(); }); //when cancel button is clicked reshow reply button $(“#cancel-comment-reply-link”).click( function() { $(“.comment-reply-link”).show(); });