<?php global $qaleb;?>
<?php
function map_post_ajax(){
    $offset = $_POST["offset"];
    $ppp = $_POST["ppp"];
    $cat = $_POST["cat"];
    header("Content-Type: text/html");
	if($cat!=null){
?>
<div class="polist">
  <?php
    $args = array(
        'post_type' => 'post',
		'posts_per_page'=> '6',
		'cat'	=>	$cat,
    );

    $loop = new WP_Query($args);
	
    while ($loop->have_posts()) { $loop->the_post(); 
	?>
<div class="item">
<div class="thumbnail">
<?php if(has_post_thumbnail()){?>
<a href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url('loop-1'); ?>" alt="<?php the_title(); ?>"></a>
<?php }else{ ?>
<img src="<?php bloginfo("template_url"); ?>/img/none.png">
<?php } ?>
 </div>
<div class="det">
<?php if(get_post_meta( get_the_ID(), 'meta-text-1', true )!=null){ ?><div class="roti"><?php echo get_post_meta( get_the_ID(), 'meta-text-1', true ); ?></div><?php } ?>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div>
</div>
  <?php
    }
?>
<div class="more"><h3><a href="<?php echo get_category_link( $cat ); ?>"> آرشیو <?php echo get_cat_name($cat); ?></a></h3>											</div>			
</div>
<?php
	}else{
		?>
        <h2>...</h2> 
<div class="posts foot">
	<p>مطلبی در مورد این استان یافت نشد!</p>
</div>
        <?php
	}
    exit; 

}

add_action('wp_ajax_nopriv_map_post_ajax', 'map_post_ajax'); 
add_action('wp_ajax_map_post_ajax', 'map_post_ajax');