Luigi Cavalieri - Coding, Sharing, Blogging

Blog / WordPress

  1. How to Register Multiple Gutenberg Blocks Each Through its Own block.json File

    How to Register Multiple Gutenberg Blocks Each Through its Own block.json File

    The development of a block-enabled plugin is a very well documented process in the WordPress Codex, packed with all the information one might need to get started. To date however, the documentation falls quite short in providing details on how a plugin should proceed to register two or more Gutenberg blocks by means of block.json configuration files. As I recently faced this problem first-hand, I thought I'd share what I learnt.

  2. How to Rename a Shortcode Programmatically

    How to Rename a Shortcode Programmatically

    It does happen to change mind. But when for some reason we change mind on the name of a shortcode become almost ubiquitous amongst our Posts, Pages and Custom Posts, the only reasonable way of renaming all its occurrences is programmatically — writing scripts all the monotonous work can be delegated to is a habit that, trust me, pays off over time.

  3. Raw Solution to Ordering an Array of Page Objects Hierarchically

    Raw Solution to Ordering an Array of Page Objects Hierarchically

    Sometimes the need arises for an array of Page objects ordered hierarchically, but all there is available is just a collection of Page objects ordered by title for example, maybe because they were previously fetched from the database through the global $wpdb object. On these occasions, to hierarchically reorder an array as such, we have to be creative, because WordPress isn't equipped with an utility function made up on purpose — or at least I have not dug enough to uncover one. In truth, I simply enjoyed looking for my own solution, and that's the main reason why I am here now writing about it.

  4. How to Delete a Whole Taxonomy from the Database

    How to Delete a Whole Taxonomy from the Database

    To carry out such a task, there is no utility function made up on purpose in WordPress. After all, deleting all the data associated to a taxonomy isn't a common task, or at least not something you routinely do. Me, for example, I ran into the problem while writing the uninstall.php script for SiteTree Pro 4.0 — a file loaded when not all the WordPress functions are available, either. But even considering a more generic context, the most streamlined solution that can be adopted is to use three custom queries:

  5. The 'db-error.php' Plugin

    The 'db-error.php' Plugin

    In the WordPress jargon a Drop-in Plugin is a PHP script that replaces a functionality of WordPress, somehow becoming part of the core. In fact these special plugins don't need to be activated to be loaded, they just have to be dropped in the wp-content folder.