Build script
Last updated
Last updated
To create a custom block in PorterWP, follow these steps:
Begin by navigating to the theme folder where the PorterWP blocks are stored. The path is typically:
You will need the _block-base
folder and make.sh
script to generate new blocks. These files can be downloaded from the PorterWP public GitHub repository:
Place both files in your /blocks
folder.
To generate a new block, you need to run the make.sh
script from the terminal. Use the following command format:
block-name: The name of your new block (e.g., custom-hero
).
block-category (optional): The block category. If not provided, the default is components
.
Example:
This will create a new block under the /components
folder with the name test-block
.
Here is the content of the make.sh
script:
This script does the following:
Takes the block name ($NAME
) and optional block category ($CATEGORY
).
Sets a default category (components
) if none is provided.
Creates a new directory for the block inside the specified category.
Copies the contents of _block-base
into the new block folder.
Replaces placeholder values (like dummy-name
and Dummy_Title
) in the block's files with the actual block name and title.
The _block-base
folder acts as a stub for new block creation. Advanced users can modify its contents to customize the default structure of new blocks.
You are now ready to create and customize blocks in PorterWP!