<?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="title"> <span><i class="fa fa-map-marker" aria-hidden="true"></i> <?php echo get_cat_name($cat); ?></span> <div class="m-more"> <a href="<?php echo get_category_link($qaleb['defult-city']); ?>"> بیشتر ... </a> </div></div>

  <?php
    $args = array(
        'post_type' => 'post',
		'posts_per_page'=> '4',
		'cat'	=>	$cat,
    );

    $loop = new WP_Query($args);
	
    while ($loop->have_posts()) { $loop->the_post(); 
	?>	   	
			<div class="map-img">	
			<?php if(has_post_thumbnail()){?><a href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url('img-145'); ?>" alt="<?php the_title(); ?>"></a>
          <?php }else{ ?><img src="<?php bloginfo("template_url"); ?>/img/none.png"><?php } ?>			   	
         <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
		 </div>
		 <?php
    }
?>
<?php
	}else{
		?>
<div class="posts-no">
<i class="fa fa-meh-o" aria-hidden="true"></i>
<h3>مطلبی در مورد این استان یافت نشد!</h3>
</div>
        <?php
	}
    exit; 

}

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