<?php
// Indiviudal pages taxopnomy page
?>
<?php $terms = get_the_terms( get_the_id(), 'psl_catergories' );?>
<?php if ( !empty( $terms ) ){
  // get the first term
  $term = array_shift( $terms );
}
?>

<?php get_header(); ?>
<section id="content" role="main" class='individual-workshop-pls'>

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
      <?php
      $resource_link = get_field('resource_link');
      $video_link = get_field('video_link');
      ?>
      <div class='breadcrumb clear  island-bottom-half  col-12'>
        <a class='inline' href='/psl-toolkit'>Workshop Categories</a> <i class="fa fa-chevron-right" aria-hidden="true"></i> <a href='/psl_catergories/<?php echo $term->slug;?>'><?php echo $term->name; ?></a> <i class="fa fa-chevron-right" aria-hidden="true"></i> <?php echo the_title(); ?>
      </div>
      <header class="header-top col-12 island-bottom">
        <div class='inner-header'>
          <h3><span>Workshop:</span> <?php echo $term->name; ?></h3>
        </div>




      </header>
      <section class="entry-content">
        <div class='col-12 col-4-m right'>
          <h1 class="entry-title"><?php the_title(); ?></h1>
        </hr>
        <p>
          <?php echo $term->description; ?>
        </p>
        <?php if($resource_link):?>
        <a class='download-button' target='_blank' href='<?php echo $resource_link['url']; ?>'>Download Resources<i class="fa fa-chevron-down" aria-hidden="true"></i></a>
      <?php endif; ?>
      </div>
      <div class='col-12 col-8-m'>
        <?php if($video_link):?>
          <div class='img island-half-bottom video-image'>


              <div class="embed-container">
                <?php the_field('video_link'); ?>
              </div>


          </div>
        <?php endif; ?>
      </div>

    </section>
  </article>
  <?php if ( ! post_password_required() ) comments_template( '', true ); ?>
<?php endwhile; endif; ?>
</section>
<section id="content" role="main" class='container clear'>


  <div class='row gls-web island-bottom'>
    <div class='col-12 other-videos island-bottom-margin island-top'>
      <h2 class='big'>Other videos in this workshop</h2>
    </hr>

  </div>
  <!--single-pls_toolkit.php-->


    <?php
    $actual_page_id = get_the_id();

    $args = array(
      'post_type' => 'psl_toolkit',
      'posts_per_page' => -1,
      'post__not_in' => array($actual_page_id),
      'post_status' => array('publish', 'private'),
      'tax_query' => array(
        array(
          'taxonomy' => 'psl_catergories',
          'field'    => 'slug',
          'terms'    => $term->slug,
        ),
      ),
    );

    $loop = new WP_Query( $args );


    ?>

    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

      <?php //Var
      $the_id = get_the_id();
      $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 endwhile; wp_reset_query(); ?>

</div>
</section>

<?php get_footer(); ?>
<!--single-pls_toolkit.php-->
