[DevOps] WP 플러그인/테마

Email IconExcel IconBedrock Icon

wp-cli scaffold

Author
changhee1220
Date
2024-02-17 09:57
Views
37
The wp scaffold command is part of WP-CLI, which is a command-line interface for WordPress. It allows you to generate boilerplate code for themes, plugins, child themes, post types, taxonomies, and more, helping you speed up your development process. To use any wp scaffold commands, you first need to have WP-CLI installed on your system.

Here's a quick overview of some of the common scaffolding commands you might find useful:

 

Scaffold a Plugin

To generate the basic files needed for a WordPress plugin: bash wp scaffold plugin <plugin-name> Replace <plugin-name> with the desired name of your plugin. This will create a new plugin directory with a PHP file containing the plugin header, a readme file, and optionally, tests and GitHub configuration.


Scaffold a Theme

To generate a new underscores-based theme: bash wp scaffold _s <theme-name> --theme_name="<Theme Name>" --author="<Author Name>" Replace <theme-name><Theme Name>, and <Author Name> with your desired theme directory name, theme name, and author name respectively. This command creates a basic underscores theme with the specified parameters.

 

Scaffold Child Theme

To create a child theme: bash wp scaffold child-theme <child-theme-name> --parent_theme=<parent-theme-slug> Ensure you replace <child-theme-name> with your desired child theme name and <parent-theme-slug> with the slug of the parent theme.

 

Scaffold Custom Post Type

To quickly generate PHP code that registers a custom post type: bash wp scaffold post-type <custom-post-type-name> Replace <custom-post-type-name> with the name of your custom post type. This command will output the necessary PHP code, which you can then copy into your theme's functions.php file or into a plugin.

 

Scaffold Taxonomy

Similarly, to generate code for a custom taxonomy: bash wp scaffold taxonomy <custom-taxonomy-name> --post_types=<post-type> Replace <custom-taxonomy-name> with your taxonomy name and <post-type> with the post type to associate this taxonomy with. This will give you the PHP code to register a custom taxonomy.

 

Before You Start

Before running any wp scaffold commands, make sure you're in the root directory of your WordPress installation in your terminal or command prompt. This is where the wp-config.php file is located.

WP-CLI and its scaffolding capabilities can greatly accelerate your theme and plugin development by generating boilerplate code that adheres to WordPress coding standards. For more details and options available for each scaffolding command, you can run wp help scaffold <command> in your terminal to get specific help for each command (replace <command> with plugintheme, etc.).

If you have any specific scaffolding needs or questions, feel free to ask!