<?php
/**
 * This file is used for your staff post entry
 * @package Ultra WordPress Theme
 * @since 1.0
 * @author AJ Clarke : http://wpexplorer.com
 * @copyright Copyright (c) 2012, AJ Clarke
 * @link http://wpexplorer.com
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

/******************************************************
 * Single Posts
 * @since 1.0
*****************************************************/
if ( is_singular() && is_main_query() ) {
	
	
	// Show featured image
	if( has_post_thumbnail() ) { ?>
		<div id="staff-post-thumbnail">
			<?php if( get_post_meta(get_the_ID(), 'wpex_post_layout', true ) !== 'Full Width' ) { ?>
				<img src="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id() ),  wpex_img( 'staff_post_width' ), wpex_img( 'staff_post_height' ), wpex_img( 'staff_post_crop' ) ); ?>" alt="<?php echo the_title(); ?>" />
			<?php } else { ?>
				<img src="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id() ),  wpex_img( 'staff_post_full_width' ), wpex_img( 'staff_post_full_height' ), wpex_img( 'staff_post_full_crop' ) ); ?>" alt="<?php echo the_title(); ?>" />
			<?php } ?>
		</div><!-- #staff-post-thumbnail -->
	<?php }

		
/******************************************************
 * Entries
 * @since 1.0
*****************************************************/
} else {
	
	// Globals
	global $wpex_staff_count;
	
	// Columns
	$wpex_grid_class = of_get_option('staff_archive_columns','3'); ?>
	
    <article class="staff-entry grid-<?php echo $wpex_grid_class; if ( $wpex_staff_count == $wpex_grid_class ) echo ' remove-margin'; ?>">
		<?php
        // Featured Image
        if( has_post_thumbnail() ) { ?>
        	<div class="staff-entry-media">
                <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="staff-entry-img">
                    <img src="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id() ),  wpex_img( 'staff_entry_width' ), wpex_img( 'staff_entry_height' ), wpex_img( 'staff_entry_crop' ) ); ?>" alt="<?php echo the_title(); ?>" />
                </a><!-- .staff-entry-img -->
            </div><!-- .staff-entry-media -->
        <?php } ?>
        <div class="staff-entry-details clearfix">
            <header class="staff-entry-title">
                <h2>
                    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
                    <?php
                    // Staff position
                    if(get_post_meta( get_the_ID(), 'wpex_staff_position', true) !=='') { ?>
                        <div class="staff-entry-position"><span class="icon-double-angle-right"></span><?php echo get_post_meta( get_the_ID(), 'wpex_staff_position', true); ?></div>
                    <?php } ?>
                </h2>
            </header>
            <div class="staff-entry-excerpt">
				<?php
                // Excerpt
                if(empty( $post->post_excerpt )) {
                        echo wp_trim_words( strip_shortcodes( get_the_content() ), of_get_option( 'staff_entry_excerpt_trim', '20' ) ); ?>
                        <a href="<?php the_permalink(); ?>" title="<?php _e('read more','wpex'); ?>" class="staff-entry-readmore"><?php _e('read more','wpex'); ?> &rarr;</a>	
                <?php } else {
					echo apply_filters('the_content', get_the_excerpt());
				} ?>
            </div><!-- .staff-entry-content -->
        </div><!-- .staff-entry-details -->
    </article><!-- .staff-entry -->
    
<?php
if ( $wpex_staff_count == $wpex_grid_class ) {
	echo '<div class="clear"></div>'; // Clear Floats
	$wpex_staff_count=0; // Reset post counter
}
$wpex_grid_class = NULL; // Nullify var
}