custom-content-shortcode icon indicating copy to clipboard operation
custom-content-shortcode copied to clipboard

array not working for standard custom field with multiple values

Open codemonkeynorth opened this issue 5 years ago • 2 comments

see discussion here https://wordpress.org/support/topic/accessing-multiple-value-from-a-custom-field/

it should be possible to create a custom field in wordpress multiple times with different values and then process this with [array myfield] or [pass array=myfield]

I've noted some potential changes on that support thread

essentially get_post_meta last parameter single=true in the CCS plugin could theoretically be changed to false to allow for this (this is standard behaviour https://www.wpbeginner.com/wp-tutorials/wordpress-custom-fields-101-tips-tricks-and-hacks/#multiplevalues)

thanks J

codemonkeynorth avatar Jun 05 '20 04:06 codemonkeynorth

Hello! Thank you for pointing me to the discussion. I appreciate that you've been exploring possible solutions with the poster.

Reading through your proposals/ideas, the last one looks good, to make [array] work as expected. I just want to make sure the change(s) will be backward compatible, that existing (short)code continues to work.

OK, I'll look into this and let you know how it goes.

eliot-akira avatar Jun 05 '20 08:06 eliot-akira

thanks. I have a few test sites I can try it on if you need me to check before release.

I noticed the default value for $single is actually false anyway, so using that with [array] would make sense I think.

get_post_meta : $single (bool) (Optional) If true, returns only the first value for the specified meta key. This parameter has no effect if $key is not specified. Default value: false

as mentioned it would also be useful to be able to use {0} {1} etc with either [array my_field] or [pass array=my_field] and have some way of getting the count (array length) as well.

regards J

codemonkeynorth avatar Jun 05 '20 09:06 codemonkeynorth