eliot-akira / custom-content-shortcode

Custom Content Shortcode
17 stars 6 forks source link

array not working for standard custom field with multiple values #5

Open codemonkeynorth opened 4 years ago

codemonkeynorth commented 4 years ago

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

eliot-akira commented 4 years ago

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.

codemonkeynorth commented 4 years ago

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