create plugin by wordpress cli

By using scaffold command we can create plugin and custom post type

For plugin command is following

wp scaffold plugin <slug> --plugin_name="<plugin name" --plugin_description="<plugin description>" --plugin_author="<author>" --plugin_author_uri="<author uri>" --plugin_uri="<plugin url>"




if you want to skip test then following command

wp scaffold plugin <slug> --plugin_name="<plugin name" --plugin_description="<plugin description>" --plugin_author="<author>" --plugin_author_uri="<author uri>" --plugin_uri="<plugin url>" --skip-tests

Activate plugin by cli without going to dashboard

wp plugin activate <plugin slug>




For custom post type command is following

wp scaffold post-type <slug> --label=<label> --plugin=<pluginname> --theme=<themename> --textdomain=<textdomain> --dashicon=<dashicon>

If want to put code inside theme

wp scaffold post-type <slug> --label=<label> --theme=<themename> --textdomain=<textdomain> --dashicon=<dashicon>

If want to put code inside plugin

wp scaffold post-type <slug> --label=<label> --plugin=<pluginname> --textdomain=<textdomain> --dashicon=<dashicon> 

If want to get only code of custom post type with register_post_type()

wp scaffold post-type <slug> --label=<label> --plugin=<pluginname> --textdomain=<textdomain> --dashicon=<dashicon> --raw

If want to overwrite existing code with new one for CPT

wp scaffold post-type <slug> --label=<label> --plugin=<pluginname> --textdomain=<textdomain> --dashicon=<dashicon> --force

Leave a Comment

Your email address will not be published.