ky818smKy818sm  2025-11-05 12:20 旷野小站 隐藏边栏 |   抢沙发  1 
文章评分 0 次,平均分 0.0
推荐商品
淘宝特惠商品推荐 - 点击查看详情
广告 · 通过合作链接购买,我们可能会获得佣金

安装 WP-CLI:

bash

 

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 进入 PHP 容器</span>
<span class="token function" style="color: #4078f2;">docker</span> <span class="token builtin class-name" style="color: #50a14f;">exec</span> <span class="token parameter variable" style="color: #4078f2;">-it</span> php-wordpress1 /bin/bash

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 下载 WP-CLI</span>
<span class="token function" style="color: #4078f2;">curl</span> <span class="token parameter variable" style="color: #4078f2;">-O</span> https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 验证是否可用</span>
php wp-cli.phar <span class="token parameter variable" style="color: #4078f2;">--info</span>

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 设置为全局命令</span>
<span class="token function" style="color: #4078f2;">chmod</span> +x wp-cli.phar
<span class="token function" style="color: #4078f2;">mv</span> wp-cli.phar /usr/local/bin/wp

使用 WP-CLI 管理主题和插件:

bash

 

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 进入 WordPress 目录</span>
<span class="token builtin class-name" style="color: #50a14f;">cd</span> /var/www/html

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 查看已安装的主题</span>
wp theme list --allow-root

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 查看可更新的主题</span>
wp theme list <span class="token parameter variable" style="color: #4078f2;">--update</span><span class="token operator" style="color: #4078f2;">=</span>available --allow-root

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 更新所有主题</span>
wp theme update <span class="token parameter variable" style="color: #4078f2;">--all</span> --allow-root

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 查看已安装的插件</span>
wp plugin list --allow-root

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 查看可更新的插件</span>
wp plugin list <span class="token parameter variable" style="color: #4078f2;">--update</span><span class="token operator" style="color: #4078f2;">=</span>available --allow-root

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 更新所有插件</span>
wp plugin update <span class="token parameter variable" style="color: #4078f2;">--all</span> --allow-root

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 更新单个插件</span>
wp plugin update plugin-name --allow-root

<span class="token comment" style="color: #a0a1a7; font-style: italic;"># 激活/停用插件</span>
wp plugin activate plugin-name --allow-root
wp plugin deactivate plugin-name --allow-root
声明:本站许多内容均从网上收集整理,若有内容侵犯到您的权益,请通过邮件【6167555@qq.com】联系本站,我们将及时删除!

有问题请点我联系站长

「点点赞赏,手留余香」
HIDE

声明:本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

发表评论

表情 格式 链接 私密 签到
扫一扫二维码分享