Skip Navigation

[Resuelto] Final separator in views

This support ticket is created hace 6 años, 2 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Etiquetado: ,

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Minesh hace 6 años, 2 meses.

Asistido por: Minesh.

Autor
Mensajes
#1097908

Hi,

I would like to show a list of fields separated by commas but that the last separator was different.

Example: Monday, Tuesday, Wednesday, Thursday and Friday.

I use the shortcode [types field ='days-of-the-week' separator=','] [/ types] but I would like to separate the last element with another separator.

Is it possible to do this?

#1098410

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - Yes, its possible but you need to use the custom shortcode to achieve your goal.

Try to add the following code to your current theme's functions.php file:

function func_adjust_last_element_array( $atts ){

extract( shortcode_atts( array(
        'field' => '',
    ), $atts ) );
	
$values =  explode(",",$atts['field']);
$last = array_pop($values);
$values[] = ' and '.$last.'.';

return join(", ",$values);
  
}
add_shortcode( 'adjust_array', 'func_adjust_last_element_array' );

And use the above shortcode as given under:

.
[adjust_array  field="[types field ='days-of-the-week' separator=','] [/ types]"]
#1100232

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Could you please confirm that solution I shared works for you.