<?php /*
 * Template Name: Asia Pacific Advisories
 * Template Post Type: ap-advisory
 */ ?>

<?php get_header(); ?>


<div class="container-fluid content-wrapper">
  <div class="row">
    <div class="col-12 page-head">
      <h4>Asia Pacific Events / Advisories</h4>
  </div>

  <div class="row">
    <div class="col-3 sidebar">
      <nav class="nav flex-column">
        <?php wp_nav_menu( array( 'theme_location' => 'asiapac-sidebar' ) ); ?>
      </nav>
    </div>



    <div class="col-9 main-content">

  <?php
      query_posts(array(
        'post_type' => 'ap-advisory',
          'showposts' => 10
      ) );
  ?>

 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <div class="list-container border-bottom mb-2 pb-2">
              <h5><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h5>
              <div class="hstack stack-r1 my-2 py-1 border-top border-bottom">
                <div class="p-1">
                  <span class="badge bg-warning me-1">Advisory</span>
                  <strong>Event ID:</strong> AP-<?php the_ID(); ?>
                </div>
                <div class="p-1"> <strong>Type: </strong>
                  <?php $term = get_field('event_type');
                      if( $term ): ?>

                  <?php echo esc_html( $term->name ); ?><?php endif; ?><strong> Date: </strong> <?php echo esc_html( get_field('event_date') ); ?> </div>

              </div>
              <p>Locations: <?php
              $terms = get_the_terms( $post->ID , 'asia-pacific-countries' );

              foreach ( $terms as $term ) {

                echo  '<span class="badge text-bg-light">' . $term->name . '</span> ';
                    }
              ?>


            </p>


              <p class="list-content"><?php
                  $my_content = apply_filters( 'the_content', get_the_content() );
                  $my_content = wp_strip_all_tags($my_content);
                  echo wp_trim_words( $my_content, 55, $moreLink);
                  ?>
              </p>



</div>

 <?php endwhile; else : ?>


 	<!-- The very first "if" tested to see if there were any Posts to -->
 	<!-- display.  This "else" part tells what do if there weren't any. -->
 	<p><?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?></p>


 	<!-- REALLY stop The Loop. -->
 <?php endif; ?>
<!-- LOOP END -->





      </div>
    </div>
  </div>
</div>





<?php get_footer(); ?>
