Support

Account

Home Forums Front-end Issues Implode Post Object with "," and add "and" at last word Reply To: Implode Post Object with "," and add "and" at last word

  • Thanks for the help @hube2

    To make sure I wasn’t getting empty results, I changed the ACF to relationship and used;

    <?php $locations = get_field('development_plots'); ?>
    <?php if( $locations ): ?>
    	<?php foreach( $locations as $location ): ?>
    		<span class="accent_color"><?php echo get_the_title( $location->ID ); ?></span>,
    	<?php endforeach; ?>
    <?php endif; ?>	

    To output them, which they are but obviously want the last one to have ‘and’ at the end.

    I tried the above, but that just blew it up again…