<?php
/**
 * @package OneDream
 */
?>
<div class="container-fluid page_content row ourresources">
        <div class="col-sm-12 ">
          
          <div class="row">
            <?php
 $boxvariable = array();
 for($k=1;$k<=3;$k++){?>
  <?php $boxid = absint(get_theme_mod('box'.$k));?>
  <?php $boxquery = new WP_query('page_id='.$boxid);?>
  <?php if ($boxquery->have_posts() && $boxid>0) : 
  while( $boxquery->have_posts() ) : $boxquery->the_post();    
   $thumbnail_id = get_post_thumbnail_id( $post->ID );
   $alt = esc_html(get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true));
   $image = esc_url(get_the_post_thumbnail_url( $post->ID, 'onedream-home-box-size'));
   $title = esc_html(get_the_title( $post->ID ));
   $my_postid = $post->ID;
 $content = esc_html(onedream_get_excerpt($my_postid,'250'));
  $url = esc_url(get_the_permalink($my_postid));
  $boxvariable[] = array('boxid'=>$post->ID,'boximage'=>$image,'alt'=>$alt,'box_title'=>$title,'box_content'=>$content,'url'=>$url);
  endwhile;
  wp_reset_postdata();
   endif;
  ?>
  
<?php }?>

<?php foreach($boxvariable as $boxvariables){?>
  <div class="col-md-4 text-center">
    <div class="thumbnail">
      <a href="<?php echo esc_url($boxvariables['url']);?>">
        <img src="<?php echo esc_url($boxvariables['boximage']);?>" title="<?php echo esc_attr($boxvariables['alt']);?>" class="img-responsive img-thumbnail">
        <div class="caption">
          <h2><?php echo esc_html($boxvariables['box_title']);?></h2>
          
        </div>
      </a>
      <p><?php $boxid = esc_html($boxvariables['boxid']);
      echo esc_html(onedream_get_excerpt($boxid,150));
      ?></p>
      <p><a href="<?php echo esc_url($boxvariables['url']);?>" class="btn btn-primary readmore"><?php echo esc_html__('Read More','onedream')?></a></p>
    </div>
  </div>
  <?php }?>  
  <div class="clearfix"></div>
</div>
</div><!--site-main -->
<div class="clearfix"></div>
<!--welcome to home page section start-->
<?php 
$welcome_section_variable = array();
$weclomeid = absint(get_theme_mod('welcome_section',true));
$welcomequery = new WP_query('page_id='.$weclomeid); ?>
  <?php if ($welcomequery->have_posts() && $weclomeid>0) : 
  while( $welcomequery->have_posts() ) : $welcomequery->the_post();    
   $thumbnail_id = get_post_thumbnail_id( $post->ID );
   $alt = esc_html(get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true));
   $image = esc_url(get_the_post_thumbnail_url( $post->ID, 'onedream-home-box-size'));
   $title = esc_html(get_the_title( $post->ID ));
   $my_postid = $post->ID;
 $content = esc_html(onedream_get_excerpt($my_postid,'250'));
  $url = esc_url(get_the_permalink($my_postid));
  $welcome_section_variable[] = array('boxid'=>$post->ID,'boximage'=>$image,'alt'=>$alt,'box_title'=>$title,'box_content'=>$content,'url'=>$url);
  endwhile;
  wp_reset_postdata();
   endif;
  ?>
 <?php if($weclomeid>0){?>   
  <!--welcome to home page section query end -->
<div class="col-md-12">
  <div class="panel panel-default">
    <?php foreach($welcome_section_variable as $welcome_section_variables){?>
    <div class="panel-heading"><h2 class="text-center"><?php echo esc_html($welcome_section_variables['box_title']);?></h2></div>
    <div class="panel-body"><p class="text-center"><?php echo esc_html($welcome_section_variables['box_content']); ?></p></div>
    <?php }?>
  </div><!--panel panel-default-->
</div><!--col-md-12-->
<?php }?>
       <div class="clearfix"></div>
    </div><!-- site-aligner -->