<?php get_header(); ?>

<section class="page-section main-content-section">
	<div class="container">


						<div class="singular-header">
							<div class="single-header-post-type">
									<?php 
									$postType = get_post_type_object(get_post_type());
									if ($postType) {
									    echo esc_html($postType->labels->all_items);
									}
									?>
							</div>
							<a href="<?php echo get_post_type_archive_link( get_post_type() ); ?>" class="control control-back inverse icon-arrow-thin-left">
		                        <span>Back</span>
		                    </a>
						</div>

				<h1 class="center-align"><?php echo get_the_archive_title(); ?></h1>
						
		<div class="row">
			<div class="col s12 m10 push-m1 l8 push-l2">





				
				<div class=" <?php if (isset($download) OR '' !== get_post()->post_content ) { echo ' plain_text'; } ?>">


					<div class="accordion">


						<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

 					    		<div class="accordion-item">
 					    			<div class="accordion-title">
 					    				<h3><?php the_title(); ?></h3>
 					    				<div class="chevron">
				                            <?php echo file_get_contents(get_template_directory() . '/assets/img/icons/plus.svg'); ?>
				                        </div>
 					    			</div>
 					    			<div class="accordion-content">
 					    				<div class="wysiwyg">
 					    					<?php the_content() ?>
 					    				</div>
 					    			</div>
 					    				
 					    		</div>

 						<?php endwhile; else : ?>
 							<p><?php _e( 'Sorry, nothing was found.' ); ?></p>
 						<?php endif; ?>


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

<?php 
//get taxonomies available from post type
$taxonomy_objects = get_object_taxonomies( get_post_type(), 'objects' );
$taxonomies = array();
//get all possible taxonomies, loop through into array
foreach($taxonomy_objects as $taxonomy_object) {
	array_push($taxonomies, $taxonomy_object); 
} 
?>

<section class=" page-section faq-content style-med clearfix">
	<div class="plain_text section-inner">

	<h2 class="section-title center-align">Explore more FAQs</h2>
		<div class="container">
					
			<?php 
			// foreach taxonomy, display a filter tool
			foreach ($taxonomies as $taxonomy): 			
				//get all terms 
				$terms = get_terms( $taxonomy->name, array(
					'hide_empty' => false,
				) );
				$activestate = " "; ?>

				<?php if ($terms): ?>

					<ul class="faq-term-links nospace-mobile">

						<?php foreach($terms as $term) {
							// ensure filter is set to current active term

							if ($term->name != 'Uncategorized') {
								echo '<li><a href="' . get_term_link($term) .'"><span>' . $term->name . "</span></a></li>";
							}
						} 
						?>
					</ul>

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

	</div>
</section>

<?php get_footer(); ?>
