I need to create a conditional for an image field with the active option to have more than one instance. I need to know if the field is empty or has an image.
He añadido el código personalizado y al añadir el shortcode en la vista siempre devuelve 0.
add_shortcode('get-image-field-count', 'get_image_field_count_fn');
function get_image_field_count_fn() {
What is the context where you are using the shortcode?
The code itself looks okay, assuming that the context is correct for get_the_ID to return the post ID of a post that has values for a custom field whose slug is listing-images.
Maybe try returning the result of get_the_ID() to check it is the value expected.
El contexto es que quiero una condicional para saber si un campo de imagen fuese repetible (activada la opción: ¿Campo único o se repite? Permitir varias instancias en este campo) De este modo, si el campo no contiene ninguna imagen no cargará nada.
[wpv-conditional if="( $(wpcf-listing-images) ne '' )"]
Image field is not empty!
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-listing-images) eq '' )"]
Image field is empty!
[/wpv-conditional]
That is the basic conditional for an image field with the conditional for a single image. If you see the code I have sent and the explanation above, what I need is a conditional for when the image field has the option enabled to make it a field to add more than one image. The option in the field configuration is: Allow multiple instances in this field
What is the conditional for this type of field?