Support

Account

Home Forums Front-end Issues Xav

Solved

Xav

  • Hi,

    I have a checkbox array that is being output with commas, but I’d like to change the commas to pipes.

    This is what I have:

    <?php if( get_field('work_categories') ): ?>
      <h2><?php the_field('work_categories'); ?></h2>
    <?php endif; ?>

    So instead of outputting “Value 1, Value 2, Value 3” I want it to output “Value 1 | Value 2 | Value 3”

    Thanks

  • the_field() echos the content, so you’ll need to use get_feild() and then format the value yourself.

    
    <?php 
      $value = get_field('work_categories');
      if ($value) {
        ?><h2><?php echo implode(' | ', $value); ?></h2><?php 
      }
    ?>
    
  • Perfect, thank you!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Xav’ is closed to new replies.