<?php
/**
 * The default template for displaying Document archive
 *
 * @package WordPress
 * @subpackage Charity
 * @since Charity 1.0
 */
?>
<?php get_header(); ?>
	<div class="main">
		<div class="main-head">
			<div class="main-head-image fullscreener"></div>
			<div class="main-head-content">
				<div class="grid-container">
					<div class="grid-x grid-margin-x">
						<div class="cell small-12">
							<h1 class="main-title main-title-alt"><?php single_cat_title(); ?></h1><!-- /.main-title main-title-alt -->
							<?php if (ot_get_option('wpl_breadcrumbs_status') == 'on') : ?>
								<ul class="breadcrumbs">
									<?php wplook_breadcrumbs(); ?>
								</ul><!-- /.breadcrumbs -->
							<?php endif; ?>
						</div><!-- /.cell small-12 -->
					</div><!-- /.grid-x grid-margin-x -->
				</div><!-- /.grid-container -->
			</div><!-- /.main-head-content -->
		</div><!-- /.main-head -->

		<div class="main-body">
			<section class="section-events-category">
				<div class="grid-container">
					<div class="grid-x grid-margin-x">
						<div class="content cell small-12 <?php if ( $wplook_sidebar_position == 'right') { echo "large-8";} elseif ( $wplook_sidebar_position == 'disable' ) {echo "large-12"; } else { echo " large-8 right";} ?>">

							<div class="grid-x grid-margin-x cptlist-list">


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

									$wplook_pid = $post->ID;
									$wplook_project_meta = get_post_meta($wplook_pid);
									$wplook_project_status 	=  isset($wplook_project_meta['wpl_project_status'][0]) ? $wplook_project_meta['wpl_project_status'][0] : false;
									$wplook_project_location 	=  isset($wplook_project_meta['wpl_project_location_map'][0]) ? $wplook_project_meta['wpl_project_location_map'][0] : false;
									$wpl_project_link = isset($wplook_project_meta['wpl_project_link'][0]) ? $wplook_project_meta['wpl_project_link'][0] : false;
									$wpl_project_custom_url = isset($wplook_project_meta['wpl_project_custom_url'][0]) ? $wplook_project_meta['wpl_project_custom_url'][0] : false;
									$wpl_project_custom_url_target = isset($wplook_project_meta['wpl_project_custom_url_target'][0]) ? $wplook_project_meta['wpl_project_custom_url_target'][0] : false;
								 ?>

										<?php if ( has_post_thumbnail() ) : ?>
											<div class="cell small-12 medium-5 cptlist-list-image">
												<?php if ($wpl_project_link == 'off') { ?>
													<?php the_post_thumbnail( 'medium-event'); ?>
												<?php } else { ?>

													<?php if ($wpl_project_custom_url !='') { ?>
														<a href="<?php echo $wpl_project_custom_url; ?>" target="<?php echo $wpl_project_custom_url_target; ?>"><?php the_post_thumbnail( 'medium-event'); ?></a>
													<?php } else { ?>
														<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'medium-event'); ?></a>
													<?php }
												} ?>

											</div><!-- /.cptlist-list-image -->
										<?php endif; ?>

										<div class="cell small-12 <?php if ( has_post_thumbnail() ) {echo 'medium-7';} ?> cptlist-list-content">
											<h4 class="cptlist-list-title">

												<?php if ($wpl_project_link == 'off') { ?>
													<?php the_title(); ?>
												<?php } else { ?>
													<?php if ($wpl_project_custom_url !='') { ?>
														<a href="<?php echo $wpl_project_custom_url; ?>" itemprop="name" target="<?php echo $wpl_project_custom_url_target; ?>"><?php the_title(); ?></a>
													<?php } else { ?>
														<a href="<?php the_permalink(); ?>" itemprop="name"><?php the_title(); ?></a>
													<?php }
												} ?>

											</h4><!-- /.cptlist-list-title -->

											<div class="cptlist-list-meta">
												<?php
													if ($wplook_project_location) {
														echo '<span><i class="fas fa-map-marker-alt"></i> '.esc_attr( $wplook_project_location ).'</span>';
													}
													if ($wplook_project_status) {
														echo '<span><i class="fas fa-bullhorn"></i> '.esc_attr( $wplook_project_status ).'</span>';
													}
												 ?>

											</div><!-- /.cptlist-list-meta -->

											<div class="cptlist-list-entry">
												<p itemprop="description">
													<?php echo wplook_short_excerpt(ot_get_option('wpl_projects_excerpt_limit')); ?>
												</p>
											</div><!-- /.cptlist-list-entry -->
										</div>

								<?php endwhile; ?>
								<?php else : ?>
									<h2><?php _e('Sorry, no posts matched your criteria.', 'charity-wpl'); ?></h2>
									<p><?php _e('Try again later.', 'charity-wpl'); ?></p>
								<?php endif; ?>
								<?php wp_reset_postdata(); ?>

							</div><!-- /.grid-x grid-margin-x -->

							<div class="grid-x grid-margin-x">
								<div class="cell">
									<?php wplook_pagination() ?>
								</div>
							</div><!-- /.grid-x grid-margin-x -->
						</div><!-- /.cell small-12 -->
					<div id="sidebar" class="cell large-3 large-offset-1">
						<div class="sidebar">
							<?php dynamic_sidebar( 'project-1' ); ?>
						</div>
					</div>
				</div><!-- /.grid-x grid-margin-x -->
			</div><!-- /.grid-container -->
		</div><!-- /.main -->
<?php get_footer(); ?>
