Build script
To create a custom block in PorterWP, follow these steps:
Step 1: Navigate to the Theme Folder
Begin by navigating to the theme folder where the PorterWP blocks are stored. The path is typically:
Step 2: Download the _block-base and make.sh Files
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.
Step 3: Run the make.sh Script to Create a Block
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
.
Step 4: Understanding the make.sh Script
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
andDummy_Title
) in the block's files with the actual block name and title.
Step 5: Modify the _block-base as Needed
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!
Last updated