A
A
Alexander Mishchenko2020-05-24 17:25:16
WordPress
Alexander Mishchenko, 2020-05-24 17:25:16

How to display the entire value of a custom field with a check of these values?

There is a custom taxonomy Service and 6 services are nested in it.
On the page output through the loop these services.

$terms = get_field('service');
      if( $terms ): ?>
        
        <?php foreach( $terms as $term ): ?>
          <?php $r++; ?>
          <li class="cat-item cat-item-3"><a href="<?php echo get_term_link( $term ); ?>"><?php echo $term->name; ?></a></li>
        <?php endforeach; ?>

Only those services that are specified in the entry are displayed. And how to make it so that there would be a list of all services, and those that were available were marked (For example, if the service is not available, it is crossed out and there is a cross next to it, and the one that is available will have a tick next to it).

I tried to put a condition in the middle of the loop, but if there is no field, then nothing can be displayed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2020-05-24
@xxxsanchosxxx

And how is $terms stored, the key is the term ID there?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question