<?php
$tw_categories = ag_get_cats_array( 3 );   // get all post categories
$post_type     = get_post_type();
?>

<div class="one-half isobrick <?php if ( isset($tw_categories[0]->term_id) ) { echo 'highlight_category_' . $tw_categories[0]->term_id; } ?>">
	<div class="isobrick-inner">
		<?php if ( has_post_thumbnail() ) : ?>
			<a class="brick-thumb-link" href="<?php the_permalink(); ?>" alt="<?php the_title_attribute(); ?>">
				<?php
					// Get thumbnail info
					$full 		= get_post_meta($post->ID,'_thumbnail_id',false); // Get Image ID
					$thumb 		= wp_get_attachment_image_src( get_post_thumbnail_id(), 'regular');
					$alt 		= get_post_meta($full, '_wp_attachment_image_alt', true); // Alt text of image
				?>
				<img src="<?php echo esc_url( $thumb[0] ); ?>" alt="<?php if ($alt) { echo str_replace('"', "", $alt); } else { the_title_attribute(); } ?>" title="<?php the_title_attribute(); ?>" class="scale-with-grid"/>

				<div class="overlay"></div>

				<?php echo themewich_review_circle('none', false); ?>

				<?php if ( 'post' == $post_type ) : ?>
					<span class="thumboverdate">
						<i class="fa fa-bookmark"></i>
						<?php themewich_date('human'); ?>
					</span>
				<?php endif; ?>

			</a>
		<?php endif; ?>

		<h2 class="title">
			<a href="<?php the_permalink(); ?>" alt="<?php the_title_attribute(); ?>">
				<?php the_title(); ?>
			</a>
		</h2>

		<?php if ( 'product' == $post_type ) : ?>
			<div class="tiny-details">
				<?php
					/**
					 * woocommerce_after_shop_loop_item_title hook
					 *
					 * @hooked woocommerce_template_loop_rating - 5
					 * @hooked woocommerce_template_loop_price - 10
					 */
					do_action( 'woocommerce_after_shop_loop_item_title' );
				?>
			</div>
		<?php else: ?>
			<div class="tiny-details">

				<span class="author">
					<?php _e( 'By', 'themewich' ); ?>
					<span itemprop="author">
						<?php tw_author_link( 'posts' ); ?>
					</span>
				</span>

				<span class="tw-bullet">&nbsp;&bull;&nbsp;</span>

				<?php echo ag_get_cats( 3, true ); ?>

			</div>

			<div class="regularcontent">
				<?php
					global $more; $more = 0;
					if ( preg_match( '/<!--more/', $post->post_content ) ) {
						echo apply_filters( 'the_content', get_the_content( esc_html__( 'Read More', 'themewich' ) ) );
					} else {
						the_excerpt();
					}
				?>
			</div>
		<?php endif; ?>
	</div>
</div>