<?php
$count = 0;

if (have_posts()) : while (have_posts()) : the_post();
    $count++;
    $image_thumb = '';
    							
    if(has_post_thumbnail(get_the_ID(), 'blog_half_ft'))
    {
        $image_id = get_post_thumbnail_id(get_the_ID());
        $image_thumb = wp_get_attachment_image_src($image_id, 'blog_half_ft', true);
    }
?>
    
    
<!-- Begin each blog post -->
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <div class="post_wrapper half<?php if($count%2==0) { ?> last<?php } ?>">
    
    	<?php
    		if(!empty($image_thumb))
    		{
    	?>
    	
    	<div class="post_img">
    		<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    			<img src="<?php echo $image_thumb[0]; ?>" alt="" class=""/>
    		</a>
    	</div>
    	
    	<?php
    		}
    	?>
    	
    	<div class="post_inner_wrapper half">
    	
    	<div class="post_header_wrapper half">
    		<div class="post_header half">
    			<h4>
    				<a style="font-family:BYekan;" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    			</h4>
    		</div>
    		
    		<br class="clear"/>
    		
    		<div class="post_detail half">
	    		<div class="one_half" style="float:right;">
	    			<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/clock.png" class="middle"/>&nbsp;<?php echo get_the_time('j F Y'); ?><br/>
	    			<img  src="<?php echo get_stylesheet_directory_uri(); ?>/images/author.png" class="middle"/>&nbsp;<?php echo _e( 'Posted by', THEMEDOMAIN ); ?> <?php echo get_the_author(); ?>
	    		</div>
	    		
	    		<a href="<?php the_permalink(); ?>" class="post_comment_number"><?php comments_number('0 دیدگاه', '1 دیدگاه', '% دیدگاه'); ?></a>
    		</div>
    	</div>
    	
    	<br class="clear"/><br/><hr/>
    	
    	<p>
    		<?php
            	echo pp_substr(strip_tags(strip_shortcodes(get_the_content())), 200);
            ?>
    	</p>
    		
    	<a href="<?php the_permalink(); ?>" class="readmore" style="float:right;"><?php echo _e( 'Read more', THEMEDOMAIN ); ?> &larr; </a>
    	<?php 
		    $pp_enable_rating = get_option('pp_enable_rating');
		    
		    if(!empty($pp_enable_rating))
		    {
		?>
	        <div class="post_category_rating"style="float:left;">
	        	<?php echo do_shortcode('[ratings id="'.get_the_ID().'" results="true"]'); ?>
	        </div>
	    <?php
	        }
	    ?>
    	
    	</div>
    	
    </div>
</div>
<!-- End each blog post -->
    
    <?php
    if($count%2==0 OR ($count%2==1 && $count==count( $posts )))
    {
    ?>
    <br class="clear"/>
    <?php
    }
    ?>

<?php endwhile; endif; ?>

<div class="pagination">
     <?php 
     	if (function_exists("wpapi_pagination")) {
     		wpapi_pagination($wp_query->max_num_pages); 
     	}
     ?>
 </div>