Category: Code Snippets
-
WordPress Block Variation: Unlocking it’s Power
The WordPress Block Variation API allows developers to create variations of existing blocks, maintaining core functionality and scalability. Learn to create a block variation in detail.
-
Create a tag in Git
Creating tags from the command line To create a tag on your current branch, run the following commands in your terminal: Add -a to generate an Β annotated tag if you want to include a description with your tag:: This will generate a local tag containing the current state of the branch you’re working on. Tags…
-
Disable Gutenberg (Block Editor)
Totally disable Gutenberg in whole site Disable Gutenberg in specific Post type.
-
Gutenberg List all Blocks
If you want to get list of all blocks then you can use getBlockTypes from block store. We can use @wordpress/blocks package to retrieve block store. useSelect hook from @wordpress/data package will be used to access getBlockTypes function from block store. It can only be used in a component. Here is an example
-
Regex to match any number of white spaces
Incase we need to find any number of white spaces like for following silly example Here I want to replace header with another selector for example “section{“. So we want to match “header” tag, white spaces and “{” so that we only replace header selector. This is how we do in JavaScript: This is how…
-
HTML5 textarea placeholder not appearing
I encountered a weird issue while working on a form. I added a textarea and its placeholder attribute but the place holder attribute was not showing. Here is my initial code. I google it and found this stackoverflow link and gave me the solution. Solution: We need to have textarea opening and closing tag in…