最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp cli - How do I deactivate widgets by name?

programmeradmin0浏览0评论

I cna get list of widgets with

wp widget list sidebar-1

| search          | search-2          | 1 | {"title":""}
| recent-posts    | recent-posts-2    | 2 | {"title":"","number":5}
| recent-comments | recent-comments-2 | 3 | {"title":"","number":5}
| categories      | categories-2      | 4 | {"title":"","count":0}
| meta            | meta-3            | 5 | {"title":""}

I can deactivate meta plugins with:

wp widget deactivate meta-3

My problem is: how can I get the id meta-3 from widget list ? or any other method to deactivate some widgets like meta, recent-comments etc

I cna get list of widgets with

wp widget list sidebar-1

| search          | search-2          | 1 | {"title":""}
| recent-posts    | recent-posts-2    | 2 | {"title":"","number":5}
| recent-comments | recent-comments-2 | 3 | {"title":"","number":5}
| categories      | categories-2      | 4 | {"title":"","count":0}
| meta            | meta-3            | 5 | {"title":""}

I can deactivate meta plugins with:

wp widget deactivate meta-3

My problem is: how can I get the id meta-3 from widget list ? or any other method to deactivate some widgets like meta, recent-comments etc

Share Improve this question edited Aug 14, 2019 at 22:44 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Aug 14, 2019 at 22:14 yarekyarek 1274 bronze badges 3
  • 1 Like using the parameters --fields and --format for example? – Nicolai Grossherr Commented Aug 14, 2019 at 23:00
  • yes: worked with JSON format: thanks – yarek Commented Aug 15, 2019 at 10:15
  • My pleasure, I'm adding it as an answer, to conclude this thread. – Nicolai Grossherr Commented Aug 15, 2019 at 10:36
Add a comment  | 

1 Answer 1

Reset to default 1

Try using the --fields and --format parameter, e.g.

wp widget list sidebar-1 --fields=id --format=json

Docs: WP-CLI Commands wp widget list

发布评论

评论列表(0)

  1. 暂无评论