Timeline for get_post_meta / update_post_meta array
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 4, 2019 at 10:19 | vote | accept | Arg Geo | ||
Aug 4, 2019 at 2:29 | comment | added | Pat J | Also, if the answer works for you, please feel free to mark it as Accepted. | |
Aug 4, 2019 at 2:28 | comment | added | Pat J |
A post can have multiple metadata set on it, using the same key. So setting $single to true tells WordPress that you want only the first entry to be returned. Leaving it false will return all the entries in an array. Since you want a list of users, it's better to set just one metadata entry, and save it as an array.
|
|
Aug 4, 2019 at 0:02 | comment | added | Arg Geo | Thank you very much, code tested and works like a charm! I really appreciate it! | |
Aug 3, 2019 at 23:34 | comment | added | Arg Geo | Also I do not get why $single is set to true since I am searching for the user's ID which will not necessarily be the first object in the array. Edit: I read this answer (wordpress.stackexchange.com/a/245505/15801) which explains it but still can't get it... | |
Aug 3, 2019 at 23:29 | comment | added | Arg Geo | Thank you for the effort put in offering a solution to my problem. I can't try the code at this moment but will do later and let you know. Leaving $single unset was on purpose as I read in wordpress codex it has to be false (as is by default) otherwise the meta_key accepts only one value and replaces it with the latest, if one provided. Something else about $readers = array(); I had the impression, as I read on wordpress documentation that wordpress perceives $readers as an array by default so why declare it? | |
Aug 3, 2019 at 21:31 | history | answered | Pat J | CC BY-SA 4.0 |