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
1 Answer
Reset to default 1Options 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()
.