admin管理员组文章数量:1201373
hey guys i'm trying to import my plugin option into wordpress with php but i can't find any tutorial or describe about this section
i have this example:
my option name:
get_option('meow');
what i have in this option are
'cats'=> '2',
'food' => array('tona','fish'),
so how can i use
update_option
to import this values? i tried this way but it's not working
update_option('meow', 'cats','5');
hey guys i'm trying to import my plugin option into wordpress with php but i can't find any tutorial or describe about this section
i have this example:
my option name:
get_option('meow');
what i have in this option are
'cats'=> '2',
'food' => array('tona','fish'),
so how can i use
update_option
to import this values? i tried this way but it's not working
update_option('meow', 'cats','5');
Share
Improve this question
edited Jun 14, 2022 at 8:30
fuxia♦
107k38 gold badges255 silver badges459 bronze badges
asked Jun 14, 2022 at 3:54
Ahmed javaAhmed java
153 bronze badges
1 Answer
Reset to default 0Just pass the array as the second argument to update_option
- WordPress will serialize the value before storing it in the database, and automatically unserialize it when you read it:
update_option( 'meow', array(
'cats' => '2',
'food' => array( 'tona', 'fish' ),
) );
$meow = get_option( 'meow' );
print_r( $meow );
// Array
// (
// [cats] => 2
// [food] => Array
// (
// [0] => tona
// [1] => fish
// )
// )
本文标签: How Can i import plugin option
版权声明:本文标题:How Can i import plugin option? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738543720a2096002.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论