A WordPress plugin that provides a custom Gutenberg block for creating stylized anchor links to other posts, and a WP-CLI command to search for posts containing these blocks.
- Gutenberg Block: Adds a custom block that allows editors to search for and select a published post to insert as a stylized anchor link.
- WP-CLI Command: Adds a command to search for posts containing the custom Gutenberg block within a specified date range.
-
Download and Install the Plugin:
- Download the plugin ZIP file.
- Go to your WordPress Admin Dashboard.
- Navigate to
Plugins > Add New > Upload Plugin
. - Choose the downloaded ZIP file and click
Install Now
. - Activate the plugin after installation.
-
Manual Installation:
- Extract the ZIP file.
- Upload the
dmg-read-more
folder to the/wp-content/plugins/
directory. - Activate the plugin through the
Plugins
menu in WordPress.
-
Add the Block:
- Create or edit a post/page.
- In the Gutenberg editor, add a new block and search for "Read More".
- Select the "Read More" block.
-
Search and Select a Post:
- Use the Inspector Controls to search for a post by title.
- Select a post from the search results.
- The block will display a stylized anchor link with the text "Read More: {Post Title}" linking to the selected post.
-
Run the Command:
- Open your terminal.
- Navigate to your WordPress installation directory.
- Use the following command to search for posts containing the custom Gutenberg block:
wp dmg-read-more search --date-before=<YYYY-MM-DD> --date-after=<YYYY-MM-DD>
- If the date arguments are omitted, the command defaults to the last 30 days.
-
Command Arguments:
--date-before=<YYYY-MM-DD>
: Specify the end date for the search range.--date-after=<YYYY-MM-DD>
: Specify the start date for the search range.
-
Output:
- The command outputs the post IDs of the matching results.
- If no posts are found, or any other errors occur, an appropriate message is displayed.
dmg-read-more/ |-- dmg-read-more.php |-- includes/ | |-- block.php | |-- cli.php |-- src/ | |-- block.js
- Registers the Gutenberg block and WP-CLI command.
- Defines the server-side registration and rendering of the custom Gutenberg block.
- Defines the client-side functionality of the custom Gutenberg block.
- Implements the custom WP-CLI command.