/*******************agr post pehly say bani hwe hai like (blogs post) to phr just loop chalainge or values get karwainge*****************************/


function post_loop(){
    ob_start();
    
    $args = array(
         'post_type' => 'post',
         'posts_per_page' => -1,
         );
         
    $data = new WP_Query($args);
    ?>
    
    <div class="row">
        
    <?php
    if($data->have_posts()):
        while($data->have_posts()):
            $data->the_post();
            $categories =  get_the_category($post->ID);
    ?>
    
    <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
        
    <div class="main-post">
        
        <div class="blog-fig">
            <?php the_post_thumbnail('full'); ?>
        </div>
        
        <div class="blg-content">
            <div class="bld-category">
                 <?php
            foreach($categories as $category):
                echo $category->name;
            endforeach;
            ?>
            </div>
            <div class="blg-ttl"><h2><?php the_title(); ?></h2></div>
            <div class="blg-excerp">
                <?php
                   echo wp_trim_words( get_the_content(), 40, '...' );
                ?>
            </div>
             <div class="pub-date"><?php $post_date = get_the_date( 'j F Y' ); echo $post_date; ?></div> 
             <div class="blg-btn"><a href="<?php the_permalink(); ?>">Read More</a></div> 
        </div>
    </div>

    </div>
    
            
            
            <?php 
            endwhile;
    endif;
    ?>
    </div>
    
    <?php
    wp_reset_postdata();
    return ob_get_clean();
}
add_shortcode('wp_post_data','post_loop');