<?php
 $link_audio = get_post_meta(get_the_ID(),'_cmb_link_audio', true);
 $link_video = get_post_meta(get_the_ID(),'_cmb_link_video', true);
get_header();
?>
<!-- subheader begin -->
<section class="rich-header">            
  <h1 class="page-title"><?php the_title(); ?></h1>
</section>

<!-- subheader close -->

<!-- CONTENT BLOG -->



  <div id="content">
    <div class="container">
        <div class="row">

            <div class="col8">
            <?php while (have_posts()) : the_post(); ?>
                <ul class="blog-list">
                  <li>
                    <div class="preview">
                      <?php $format = get_post_format(); ?>
                      <?php if($format=='audio'){ ?>
                        <div class="post-media">
                          <iframe style="width:100%" src="<?php echo esc_url($link_audio); ?>"></iframe>
                        </div>
                      <?php } elseif($format=='video'){ ?>
                        <div class="post-media">
                          <iframe height="430" width="100%" src="<?php echo esc_url($link_video); ?>"></iframe>
                        </div>
                      <?php } elseif($format=='gallery'){ ?>
                        <div id="owl-demo-<?php the_ID(); ?>" class="post-media post-gallery">
                        <?php if( function_exists( 'rwmb_meta' ) ) { ?>
                        <?php $images = rwmb_meta( '_cmb_images', "type=image" ); ?>
                        
                          <?php 
                          foreach ( $images as $image ) { 
                          ?>
                          <?php $img = $image['full_url']; ?>
                          <img src="<?php echo esc_url($img); ?>" alt="">
                          <?php } ?> 
                        
                        <?php } ?> 
                        </div>
                        <script type="text/javascript">
                          (function ($) { 
                          "use strict";
                            $("#owl-demo-<?php the_ID(); ?>").owlCarousel({
                              slideSpeed: 400,
                              paginationSpeed: 400,
                              rewindSpeed: 800,
                              singleItem: true
                            });
                          })(jQuery);
                        </script>
                      <?php } elseif($format=='image') { ?>
                        <?php if( function_exists( 'rwmb_meta' ) ) { ?>
                        <?php $images = rwmb_meta( '_cmb_image', "type=image" ); ?>
                        <div class="post-media">
                          <?php  
                          foreach ( $images as $image ) { 
                          ?>
                          <?php $img = $image['full_url']; ?>
                          <img src="<?php echo esc_url($img); ?>" alt="">
                          <?php } ?> 
                        </div>
                        <?php } ?>
                      <?php } ?>
                    <h3 class="blog-title"><?php the_title(); ?></h3>
                    <div class="post-meta">
                      <span class="date"><i class="fa fa-calendar-o"></i><?php the_time('M d, Y'); ?></span>
                      <span class="author"><i class="fa fa-pencil-square-o"></i><?php the_author(); ?></span>
                      <span class="comments"><i class="fa fa-comment-o"></i><?php comments_number( __('0 comment', 'startos'), __('1 comment', 'startos'), __('% comments', 'startos') ); ?></span>
                    </div>
                    <div class="content-page">
                      <?php the_content(); ?>
                    </div>                    
                    <?php
                        wp_link_pages( array(
                            'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'startos' ) . '</span>',
                            'after'       => '</div>',
                            'link_before' => '<span>',
                            'link_after'  => '</span>',
                            'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'startos' ) . ' </span>%',
                            'separator'   => '<span class="screen-reader-text">, </span>',
                        ) );
                    ?>
                    <?php if(has_tag()) { ?>
                    <span>
                      <i class="fa fa-tag"></i> <?php the_tags('', ', ' ); ?>
                    </span> 
                    <?php } ?>
                  </div>                    
                </li>
              </ul>
              <?php endwhile;?>

              <?php 
                // Previous/next post navigation.
                the_post_navigation( array(
                  'next_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Next', 'startos' ) . '</span> ' .
                    '<span class="screen-reader-text">' . __( 'Next post:', 'startos' ) . '</span> ' .
                    '<span class="post-title">%title</span>',
                  'prev_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Previous', 'startos' ) . '</span> ' .
                    '<span class="screen-reader-text">' . __( 'Previous post:', 'startos' ) . '</span> ' .
                    '<span class="post-title">%title</span>',
                ) ); 
              ?>
              <div class="clearfix"></div>
              <br>

              <?php if ( comments_open() || get_comments_number() ) : ?>
              <div id="blog-comment">
                <div class='comments-box'>
                  <?php comments_number( __('0 comment', 'startos'), __('1 comment', 'startos'), __('% comments', 'startos') ); ?>
                </div>                
                <?php comments_template(); ?>                  
              </div>
              <?php endif; ?>
              
            </div>

            <div class="col4">
                <?php get_sidebar();?>
            </div>

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





  <!-- END CONTENT BLOG -->

<?php get_footer(); ?>	











  