<?php
// Every taxopnomy page
?>
<?php get_header(); ?>
<section id="content" role="main" class='container'>
  <?php $termsQuery = get_queried_object();?>


  <?php
  $posts = get_posts(
  array('post_type' => 'psl_toolkit',
  'post_status' => 'publish',
  'posts_per_page' => -1,
  'tax_query' => array(
    array(
      'taxonomy' => 'psl_catergories',
      'field' => 'id',
      'terms' => $termsQuery->term_taxonomy_id,
    )
  )
)
);
?>


<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  <header class="header">
    <?php if( !empty( $posts )):?>
      <div class='breadcrumb island-bottom-half  clear'>
        <a class='inline' href='/psl-toolkit/'>Workshop Categories</a> <i class="fa fa-chevron-right" aria-hidden="true"></i>  <?php echo $termsQuery->name; ?>
      </div>
      <h1 class="entry-title"><?php echo $termsQuery->name; ?></h1>
      <p>
        <?php echo $termsQuery->description; ?>
      </p>
    <?php else:?>
      <h1>Sorry <?php echo $termsQuery->name; ?> has no content</h1>
    <?php endif; ?>
  </header>

</article>



<div class='row gls-web island-bottom'>

  <?php foreach($posts as $post):?>
    <?php //Var
    $excert = get_field('excert');
    $care_resources = get_field('care_resources');
    $replacement_feature_image = get_field('replacement_feature_image');
    ?>
    <div class='col-12 col-4-m island-bottom-margin'>
      <a href='<?php the_permalink(); ?>'>
        <div class='inner' data-match-height="web-height">

          <?php if($replacement_feature_image):?>
            <div class='img island-half-bottom'>
              <img class='full-width' src="<?php echo $replacement_feature_image['url'];?>" />
            </div>
          <?php endif; ?>

          <h2 class='island-half' data-match-height="title-height"><?php echo $post->post_title; ?></h2>
          <?php if($excert):?>
            <div class='description' data-match-height="desc-height">
              <?php echo ShortenText($excert); ?>
            </div>
          <?php endif; ?>

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

  <?php endforeach; wp_reset_query(); ?>

</div>
</section>


<?php get_footer(); ?>
<!--Taxonomy.php-->
