View file StuffPost/stuffpost/parts/sections.php

File size: 10.83Kb
<?php /* HOME PAGE SECTIONS */

function weart_section( $args = array() ){
  // settings
    $tag = !isset($args['tag'])? '' : $args['tag'];
    $cat = !isset($args['cat'])? '' : $args['cat'];
    $offset = !isset($args['offset'])? '' : $args['offset'];
    $layout = !isset($args['layout'])? 1 : $args['layout'];
    $logo = !isset($args['logo'])? 0 : $args['logo'];

  // global variables
    global $post; $i=0;
    $args = array(
      'cat'=>$cat,
      'tag' => $tag,
      'numberposts' => 10,
      'offset' => $offset
    );
    $section_posts = get_posts( $args );

  // section title
    $display = '';
    if( $cat !== '' ){ $display .= get_cat_name( $cat ).' '; }
    if( $tag !== '' ){ $display .= $tag; }
  ?>

  <?php /* FEATURED num=5 */ if($layout===1 && $section_posts && !is_paged()): ?>
    <div class="section-featured container mb-5 mt-3 pb-5 section">
      <div class="row">
        <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
          <?php if($i<=1): ?>
            <div class='col-md-6'>
              <?php weart_itemInner( array('bg'=>'bg-65','font'=>'h3') ) ?>
            </div>
          <?php elseif($i<=4 && $i>1): ?>
            <div class="col-md-4">
              <?php weart_itemInner( array('bg'=>'bg-100','font'=>'h4') ) ?>
            </div>
          <?php endif; ?>
        <?php $i++; endforeach; wp_reset_postdata(); ?>
      </div>
    </div>
  <?php /* PROPOSER1 num=8 */ elseif($layout===2 && $section_posts && !is_paged()):  ?>
    <div class="section-proposal container mb-5 mt-3 pb-5 section">
      <!-- first row -->
        <div class="row">
          <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
            <?php if($i<=1): ?>
              <div class="col-md-6">
                <?php weart_itemInner( array('bg'=>'bg-65','font'=>'h3') ) ?>
              </div>
          <?php elseif($i<=7 && $i>1): ?>
            <div class="col-lg-4 col-md-6">
              <?php weart_itemList( array('cat'=>0,'circle'=>0) ) ?>
            </div>
          <?php endif; ?>
        <?php $i++; endforeach; wp_reset_postdata(); ?>
        </div>
    </div><!-- .section-proposal -->
  <?php /* VIDEO num=6 */ elseif($layout===3 && $section_posts && !is_paged()): ?>
    <div id="video" class="carousel slide section-video container mb-5 mt-3 pb-5" data-ride="carousel">
      <div class="row no-gutters">

          <div class="col-lg-8 position-relative">
            <div class="carousel-inner">
              <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
                <?php if($i<=5 ): ?>
                <div class="carousel-item <?php if($i==0){ ?>active<?php } ?>">
                  <?php weart_itemInner( array('bg'=>'bg-75 pb-3','font'=>'h1 col-lg-10 p-0') ); ?>
                </div>
                <?php endif; ?>
              <?php $i++; endforeach; wp_reset_postdata(); ?>
            </div>
            <a class="carousel-control-prev" href="#video" role="button" data-slide="prev">
              <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            </a>
            <a class="carousel-control-next" href="#video" role="button" data-slide="next">
              <span class="carousel-control-next-icon" aria-hidden="true"></span>
            </a>
          </div>

          <div class="col-lg-4 bg-black d-none d-lg-flex">
            <ol class="carousel-indicators pt-4">
              <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
                <?php if($i<=5 ): ?>
                  <li data-target="#video" data-slide-to="<?php echo esc_attr($i) ?>" class="c-white l-white px-3 py-2 border-bottom <?php if($i==0){ ?>active<?php } ?>">
                    <div class="row align-items-center">
                      <div class="col-3">
                        <div class="bg lazy bg-100 rounded-circle" data-src="<?php the_post_thumbnail_url( 'weart-list' ); ?>"></div>
                      </div>
                      <div class="col-8">
                        <h5 class="m-0 h6"><?php the_title() ?></h5>
                      </div>
                    </div>
                  </li>
                <?php endif; ?>
              <?php $i++; endforeach; wp_reset_postdata(); ?>
            </ol>
          </div>

      </div><!-- .row -->
    </div><!-- .section-video -->
  <?php /* POPULAR num=9 */ elseif($layout===4 && $section_posts && !is_paged()): ?>
    <div id="popular" class="carousel slide section-popular container mt-3 mb-5 pb-5" data-ride="carousel">
      <div class="position-relative">

        <div class="carousel-inner">

          <div class="carousel-item active">
            <div class="row no-gutters">
              <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
                <?php if($i<=2 ): ?>
                  <div class="col-md-4"><?php weart_itemInner( array('bg'=>'bg-75 pb-3','font'=>'h5') ); ?></div>
                <?php endif; ?>
              <?php $i++; endforeach; wp_reset_postdata(); ?>
            </div>
          </div>
          <div class="carousel-item">
            <div class="row no-gutters">
              <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
                <?php if($i<6 && $i>=3 ): ?>
                  <div class="col-md-4"><?php weart_itemInner( array('bg'=>'bg-75 pb-3','font'=>'h5') ); ?></div>
                <?php endif; ?>
              <?php $i++; endforeach; wp_reset_postdata(); ?>
            </div>
          </div>
          <div class="carousel-item">
            <div class="row no-gutters">
              <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
                <?php if($i<9 && $i>=6 ): ?>
                  <div class="col-md-4"><?php weart_itemInner( array('bg'=>'bg-75 pb-3','font'=>'h5') ); ?></div>
                <?php endif; ?>
              <?php $i++; endforeach; wp_reset_postdata(); ?>
            </div>
          </div>

        </div>

        <a class="carousel-control-prev" href="#popular" role="button" data-slide="prev">
          <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        </a>
        <a class="carousel-control-next" href="#popular" role="button" data-slide="next">
          <span class="carousel-control-next-icon" aria-hidden="true"></span>
        </a>

      </div>
    </div>
  <?php /* PROPOSER2 num=8 */ elseif($layout===5 && $section_posts && !is_paged()): ?>
    <div class="container section-proposal2 mt-3 mb-5 pb-5 section">
      <div class="row">
        <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
          <?php if($i===0 ): ?>
            <div class="col-lg-5"><?php weart_itemInner( array('bg'=>'bg-95 pb-2','font'=>'h2') ); ?></div>
          <?php endif; ?>
        <?php $i++; endforeach; wp_reset_postdata(); ?>

        <div class="col-lg-3 col-md-6">
          <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
            <?php if($i===1 || $i===2): ?>
              <div class="mb-2"><?php weart_itemInner( array('bg'=>'bg-80','font'=>'h6','cat'=>0) ); ?></div>
            <?php endif; ?>
          <?php $i++; endforeach; wp_reset_postdata(); ?>
        </div>

        <div class="col-lg-4 col-md-6">
          <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
            <?php if($i<=7 && $i>2 ): ?>
              <?php weart_itemList( array('bg_on'=>0,'font'=>'h6','excerpt'=>0) ); ?><hr class="mb-2">
            <?php endif; ?>
          <?php $i++; endforeach; wp_reset_postdata(); ?>
        </div>

      </div>
    </div>
  <?php /* FEATURED 2 num=3 */ elseif($layout===6 && $section_posts && !is_paged()): ?>
    <div class="section-featured section mb-5 mt-2 pt-1 pb-5">
      <div class="container-fluid ">
        <div class="row">
          <div class="col-lg-8">
            <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); ?>
              <?php if($i===0 ): weart_itemInner( array('bg'=>'bg-55 pb-1','font'=>'h1') ); endif; ?>
            <?php $i++; endforeach; wp_reset_postdata(); ?>
          </div>
          <div class="col-lg-4">
            <div class="row">
              <?php $i=0; foreach ( $section_posts as $post ) : setup_postdata( $post ); if($i>0 && $i<=2): ?>
                <div class="col-lg-12 col-md-6">
                  <?php weart_itemInner( array('bg'=>'bg-55','font'=>'h4','by'=>0) ); ?>
                </div>
              <?php endif; $i++; endforeach; wp_reset_postdata(); ?>
            </div><!-- .row -->
          </div><!-- .col-lg-3 -->
        </div><!-- .row -->
      </div><!-- .container-fluid -->
    </div><!-- .featured-2 -->
  <?php /* LATEST POSTS */ elseif($layout===7 && !is_single() && !is_page() ): ?>
    <div class="container section-latest mt-3 mb-5 pb-5 section">
      <div class="row infinite-scroll">
        <?php $i=0; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
          <?php if($i<=1 && has_post_thumbnail() ){ ?>
          <div class="col-lg-6 infinite-post">
            <?php weart_itemInner(array( 'font'=>'h3','bg'=>'bg-65','cat'=>0,'infinite'=>1)) ?>
          </div>
          <?php }else{ ?>
            <div class="col-lg-3 col-md-6 mb-4 infinite-post">
              <?php weart_itemGrid(array( 'font'=>'h6','bg'=>'bg-65  mb-0','excerpt'=>0,'infinite'=>1)) ?>
            </div>
          <?php } ?>
        <?php $i++; endwhile; else: weart_noposts(); endif; ?>
      </div>
      <?php $next_posts = get_next_posts_link(true); if( get_theme_mod( 'want_infinite', 1 ) &&  !empty( $next_posts ) ){ ?>
      <div class="row justify-content-center">
        <div class="infinite-more col-lg-4 col-md-6 btn bg-1 bgh-black p-2 rounded f-main c-white text-uppercase"><?php esc_html_e('More Posts','stuffpost') ?></div>
        <div class="infinite-nav d-none"><?php next_posts_link(); ?></div>
      </div>
      <?php }else{ ?>
        <div class="row">
          <?php $prev_posts = get_previous_posts_link(true); if(!empty( $prev_posts )){ ?>
            <div class="col-lg-6 mr-auto mt-4">
              <div class="btn bg-1 l-white f-main text-uppercase w-100 bgh-black rounded p-2">
                <?php previous_posts_link(); ?>
              </div>
            </div>
          <?php } $next_posts = get_next_posts_link(true); if(!empty( $next_posts )){ ?>
            <div class="col-lg-6 ml-auto mt-4">
              <div class="btn bg-1 l-white f-main text-uppercase w-100 bgh-black rounded p-2">
                <?php next_posts_link(); ?>
              </div>
            </div>
          <?php } ?>
        </div><!-- .row -->
      <?php } ?>
    </div><!-- .section-latest -->

  <?php endif; ?>

<?php }