Closed douglas-johnson closed 3 years ago
I didn't solve this exactly the same way as Shop Catalog. As I mentioned in the initial issue that version supported properties added through ACF rather than CAP and it only worked for Guest Authors.
In #10 I added a wrapper around a built-in CAP function to make something that works for CoAuthors whether they're users or Guest Authors, and only for data applied through CAP.
We may need something else later if we add data another way, but we'll cross that bridge yada yada.
Because a post can have multiple guest authors, some of the CAP functions return associative arrays.
So if for example you wanted the name of a single author, you can wind up with something like this:
get_the_coauthor_meta( 'display_name', $author->ID )[$author->ID]
But you should probably prove that the author is in the returned array first. It's not very safe.
On Shop Catalog we handled that problem as shown below, and we did roughly the same thing on Creepy Catalog.
You pass the author in question to the
shopcatalog_get_coauthor_data
function, provide the property you want and a default response.