<?php
 /* Template Name: News Template Page */
  ?>
 
<?php get_header(); ?>

        <!-- MAIN -->
      <style type="text/css">
          .headingDiv{
            padding: 50px 0px;
          }
      </style>
<main class="main-blog start-block">
 
   <div class="container news_container">
    <?php// echo do_shortcode(get_post_field('post_content', $yourpostid)); ?>
    <div class="headingDiv">
   <span><?php echo get_the_title(); ?></span>
  </div>
    <div class="row">
      

        <div id="news_post_main_div">
            
            <?php 
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                $args = array( 'post_type' => 'news', 'posts_per_page' =>9,'order' => 'ASC','paged' => $paged,);
                $the_query = new WP_Query( $args ); 
                $num = 1;
                if($the_query->have_posts()): while($the_query->have_posts()): $the_query->the_post();
                $categories = get_the_terms(get_the_ID(), 'news_taxonomy' ); 
                        ?>
                        <?php 
                 $catslug='';
                        foreach( $categories as $category ) {
                        $catslug .= $category->slug.' ';
                          }

                ?>

              <div class="news">
                <div class="news-wrapper">     
                    <img src="<?php echo get_the_post_thumbnail_url(); ?>" >
                    <div class="news_information">
                  

                    <div class="news_title">
                        <p class="text-title"><?php the_title(); ?></p>
                        </div>
                        <div class="news_category">
                            <span class="text-category"><?php echo  $catslug  ;?></span>
                        </div>
                        <div class="date_read_box">
                            <div class="date_box">
                                <?php the_time(get_option('date_format')); ?>
                            </div>
                            <div class="read_box_news">
                              <a>Read</a>
                            </div>
                        </div>

                    </div>
                </div>
            </div>   

            <?php $num++; endwhile;
            echo '<div class="custom_pagination">';
             $total_pages = $the_query->max_num_pages;
             if ($total_pages > 1){
             $current_page = max(1, get_query_var('paged'));
             echo paginate_links(array(
            'base' => get_pagenum_link(1) . '%_%',
            'format' => '/page/%#%',
            'current' => $current_page,
            'total' => $total_pages,
            'prev_text'    => __('« prev'),
            'next_text'    => __('next »'),
              ));
              }

             echo '</div>';


             endif; ?>
          
           
        </div>
        </div>
    </div>    
    <!-- .site-main -->
 </main>
<!-- .content-area -->
<?php get_footer(); ?>