<?php

$this->load->view('top');
$popular = $this->db->query("SELECT * FROM wps_blog WHERE article_id ORDER BY rand() LIMIT 20")->result_array();
?>

<section class="banner_category" style="background-image: url('<?php echo theme_url();?>images/listing/inner-banner.jpg');">
        <div class="container">
            <div class="banner_subtitle">check out over <span>200+</span></div>
            <h1 class="banner_title">Blog</h1>
        </div>
    </section>
    <div class="page_breadcrumbs">
        <div class="container">
            <ul>
                <li><a href="<?php echo base_url(); ?>" title="Home">Home</a></li>
                <li>Blogs</li>
            </ul>
        </div>
    </div>


<section class="blog_page">
        <div class="container">
            <div class="row">
                <div class="col-xxl-9 col-xl-9 col-lg-9 col-md-9 col-sm-9 col-12">
                 <h2 class="title_2">Our Blog</h2>
                 <?php foreach ($res as $key => $val) { ?>
                 <div class="blog_listing">
                    <a href="<?php echo base_url($val['friendly_url']); ?>" title="<?php echo $val['article_title']; ?>">
                        <div class="blog_thumb">                            
                            <img src="<?php echo get_image_with_name($val['article_title'], 'blog', $val['article_image'], '306', '220', 'R'); ?>" alt="<?php echo $val['article_title']; ?>" title="<?php echo $val['article_title']; ?>">
                        </div>
                        <div class="blog_content">
                            <h3 class="title_small">
                                <span><?php echo $val['article_title']; ?></span>
                            </h3>
                            <div class="blog_meta"> 
                                <span class="post_date"><i class="fa fa-clock-o"></i> <?php echo getDateFormat($val['post_date'], 3); ?></span>
                            </div>
                            <p><?php echo ($val['short_desc']); ?></p> <span class="blog_read_more_btn hover_btn">Read More <i class="fa fa-caret-right"></i></span>
                        </div>
                    </a>
                </div>
              <?php } ?>

               </div>

            <div class="col-xxl-3 col-xl-3 col-lg-3 col-md-3 col-sm-3 col-12">
                <div class="left_sidebar">
                    <div class="title_2">Popular Post</div>
                    <?php foreach($popular as $populars) { ?> 
                      <div class="right_news">
                        <a href="<?php echo base_url($populars['friendly_url']); ?>" title="<?php echo $populars['article_title']; ?>">
                            <div class="image">
                                <img src="<?php echo get_image_with_name($populars['article_title'], 'blog', $populars['article_image'], '274', '186', 'R'); ?>" alt="<?php echo $populars['article_title']; ?>" title="<?php echo $populars['article_title']; ?>">
                            </div>
                        </a>
                        <h4><a href="<?php echo base_url($populars['friendly_url']); ?>" title="<?php echo $populars['article_title']; ?>"><?php echo $populars['article_title']; ?></a></h4>
                    </div>
                  <?php } ?>                   

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



<?php $this->load->view('bottom'); ?>