<?php
/**
 * Template part for displaying each ajut with each field in category, archive, search  
 * to be used inside the loop.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Xarxaprod_theme
 */
?>

      <article id="post-<?php the_ID(); ?>" <?php post_class('xarxaprod-card-each'); ?> >

         <h3 class="entry-title">
           <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark">
             <?php the_title(); ?>
           </a>
         </h3>

         <section class="excerpt post-excerpt">
             <?php //the_excerpt() ?>
             <?php echo wp_trim_words(get_the_excerpt(), 22); // https://developer.wordpress.org/reference/functions/wp_trim_words/?>
         </section>

         <aside class="xarxaprod-associat-info">

           <section class="xarxaprod-associat-contact">
             <ul class="xarxaprod-associat-contact-fields">
               <?php if( get_field('xxp_associat_address') ): ?>
               <li class="xarxaprod-associat-address">
                 <h6>adreça / direccion:</h6>
                 <p><?php the_field('xxp_associat_address'); ?></p>
               </li>
               <?php endif; ?>

               <?php if( get_field('xxp_associat_mail') ): ?>
               <li class="xarxaprod-associat-mail">
                 <h6>mail:</h6>
                 <p><a href="mailto:<?php the_field('xxp_associat_mail'); ?>"><?php the_field('xxp_associat_mail'); ?></a></p>
               </li>
               <?php endif; ?>

               <?php if( get_field('xxp_associat_web') ): ?>
               <li class="xarxaprod-associat-web">
                 <h6>web:</h6>
                 <p><a href="<?php the_field('xxp_associat_web'); ?>" class=""><?php the_field('xxp_associat_web') ;?></a></p>
               </li>
               <?php endif; ?>

               <?php if( get_field('xxp_associat_tel') ): ?>
               <li class="xarxaprod-associat-tel">
                 <h6>tel:</h6>
                 <p><?php the_field('xxp_associat_tel'); ?></p>
               </li>
               <?php endif; ?>
             </ul>
           </section>

           <section class="xarxaprod-associat-services">
             <dt>Serveis</dt>
             <?php get_template_part(
               'template-parts/section',
               'list-checkbox',
               array('iterate_field' => 'xxp_associat_service')
             ); ?>
           </section>

         </aside>
         <nav class="more-link">
         <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark" class="button button-more">
            Més info
            <span class="hide"><?php the_title(); ?></span>
           </a>
         </nav>
       </article><!-- #post-<?php the_ID(); ?> -->
