0

I have 200 fields in for a single post. I was wondering if to put them into 1 single field as an array or multiple fields. Single array has a lot of work to be done for getting the value unlike separate fields. Which would be advisable for a large site?

Anil Astrio
  • 103
  • 1
  • 9

2 Answers2

0

It would depend on your management requirements too. If a person will be editing that custom field with a huge array in it they'd need some technical knowledge.

If management isn't important you're better off storing all the data in one field to reduce the number of times you'll be firing the get_post_meta() function. Your code will be much faster if you parse the value into an array and then work with it.

Alternatively, if you'll only need a small number of these values it would be better to run get_post_meta() a couple times than to retrieve and work with the entire array.

You can test both scenarios using this method.

Community
  • 1
  • 1
Yavor
  • 671
  • 3
  • 9
0

If you are using update_post_meta and get_post_meta then you don't need to do much work for format the data.

Ex:

$meta= array("location"=>"bangalore","time"=>"4pm","no"=>"12345678")

update_post_meta($post_id,"meta_key",$meta);

For retrieve

get_post_meta($post_id,"meta_key",true);

Riyaz
  • 89
  • 4