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

custom field - per blog metadata for plugin

programmeradmin2浏览0评论

I wish to have my plugin store metadata for each blog in a network (or just one if single site install). Most of the Google results are for post_meta and user_meta but I really need site_meta which does not appear to be the same (only a get method). The data is generally going to be of the form:

$metadata['this']['foo'] = 'something';
$metadata['this']['bar'] = 'one thing';
$metadata['that']['foo'] = 'mum';
$metadata['that']['bar'] = 'dad';

What is the best way to store this?

I wish to have my plugin store metadata for each blog in a network (or just one if single site install). Most of the Google results are for post_meta and user_meta but I really need site_meta which does not appear to be the same (only a get method). The data is generally going to be of the form:

$metadata['this']['foo'] = 'something';
$metadata['this']['bar'] = 'one thing';
$metadata['that']['foo'] = 'mum';
$metadata['that']['bar'] = 'dad';

What is the best way to store this?

Share Improve this question edited Jun 10, 2019 at 10:41 Matthew Brown aka Lord Matt asked Jun 10, 2019 at 10:34 Matthew Brown aka Lord MattMatthew Brown aka Lord Matt 1,0683 gold badges13 silver badges34 bronze badges 2
  • 3 Options are site specific, so you just need to use update_option() and get_option(). – Jacob Peattie Commented Jun 10, 2019 at 11:42
  • That is exactly what I needed. If you wrote it up as an answer... – Matthew Brown aka Lord Matt Commented Jun 11, 2019 at 10:36
Add a comment  | 

1 Answer 1

Reset to default 1

Options are site specific, so you just need to use update_option() and get_option().

The network-wide equivalents are update_network_option() and get_network_option(). Note that update_site_option() is just a wrapper for update_network_option(), and is an older name from when a multisite network was (confusingly) called a 'site'. The same applies for get_site_option().

发布评论

评论列表(0)

  1. 暂无评论