wp cli - How do I update a nested option?

I use this command to get values of ez-toc-settings->auto_insert_post_typeswp eval "print_r(get_option('ez-

I use this command to get values of ez-toc-settings->auto_insert_post_types

wp eval "print_r(get_option('ez-toc-settings')['auto_insert_post_types']);"

and this prints out the correct values:

Array
(
    [post] => post
    [page] => page
)

Now, I try to modify that so I have only "post" value I tried with:

wp eval "update_option('ez-toc-settings auto_insert_post_types', array('post'));"

Infact I have no idea on how to update a key value within a nested option.

I use this command to get values of ez-toc-settings->auto_insert_post_types

wp eval "print_r(get_option('ez-toc-settings')['auto_insert_post_types']);"

and this prints out the correct values:

Array
(
    [post] => post
    [page] => page
)

Now, I try to modify that so I have only "post" value I tried with:

wp eval "update_option('ez-toc-settings auto_insert_post_types', array('post'));"

Infact I have no idea on how to update a key value within a nested option.

Share Improve this question edited Aug 14, 2019 at 22:34 norman.lol 3,2313 gold badges30 silver badges35 bronze badges asked Aug 14, 2019 at 13:13 yarekyarek 1274 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

wp option does all you need. See wp option patch in particular.

Updates a nested value in an option.


Get a nested option value:

$ wp option pluck ez-toc-settings auto_insert_post_types

Set a nested option value (with an array):

$ wp option patch update ez-toc-settings auto_insert_post_types '{"post":"post"}' --format=json

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745240882a4618176.html

相关推荐

  • wp cli - How do I update a nested option?

    I use this command to get values of ez-toc-settings->auto_insert_post_typeswp eval "print_r(get_option('ez-

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信