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

        <!-- MAIN -->
<main class="main-blog start-block">

   <div class="container news_container">

    <div class="row">
      <?php //echo do_shortcode(get_post_field('post_content', $yourpostid)); ?>

        <div id="news_post_main_div">
            
            <?php 
                $args = array( 'post_type' => 'news', 'posts_per_page' =>-1,'order' => 'ASC', );
                $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">
                        <?php
                         $news_pdf_link_meta_box = get_post_meta($post->ID, 'news_pdf_link_meta_box', true);
                         if($news_pdf_link_meta_box){
                          ?>
                        <a href="<?php echo $news_pdf_link_meta_box ?>" target="_blank" title="Read">Read</a>
                        <?php
                        }
                        else{?>
                            <a>Read</a>
                        <?php }
                        ?>
                            </div>
                        </div>

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

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