View file StuffPost/stuffpost/index.php

File size: 2.11Kb
<?php if(!is_single()): get_header(); endif;


// POSITION variables for the order
  $p = array();
  for ($i=0; $i <= 6; $i++) {
    // default settings for the first run
    if($i===6){ $layoutDef='layout_7'; $titleDef=esc_html__('Latest Posts','stuffpost'); }
    else{ $layoutDef='off'; $titleDef=''; }

    // fill up the Array for the layout details
    $p[$i]=array(
      'layout' => get_theme_mod('hlayout_'.$i,$layoutDef),
      'cat' => get_theme_mod('hcat_'.$i),
      'tag' => get_theme_mod('htag_'.$i),
      'title' => get_theme_mod('htitle_'.$i,$titleDef),
    );
  }

// LISTING the page elements
  $pleght=count($p);
  for($i=0;$i<$pleght;$i++){

    // basic variables
      $tag = $p[$i]['tag']; if ( !empty($tag) ) { $tag = get_term_by('name', $tag, 'post_tag'); $tag = $tag->slug;}
      $cat = $p[$i]['cat']; if ( !empty($cat) ) { $cat = get_cat_ID($cat); }
      $title = $p[$i]['title'];
      $layout = $p[$i]['layout'];
      $logo = 0; if ($i===0) { $logo = 1; }

    // title
      if(  is_single() || is_page() ){
        if( $layout != 'layout_7' && !empty($title) ){ weart_sectionTitle( array('title'=>$title) ); }
      }else{
        if( !empty($title) && !is_paged()  ){ weart_sectionTitle( array('title'=>$title) ); }
      }

    //layout
      switch ( $layout ){
        case "layout_1" : weart_section( array('tag'=>$tag,'cat'=>$cat,'layout'=>1,)); break;
        case "layout_2" : weart_section( array('tag'=>$tag,'cat'=>$cat,'layout'=>2,)); break;
        case "layout_3" : weart_section( array('tag'=>$tag,'cat'=>$cat,'layout'=>3,)); break;
        case "layout_4" : weart_section( array('tag'=>$tag,'cat'=>$cat,'layout'=>4,)); break;
        case "layout_5" : weart_section( array('tag'=>$tag,'cat'=>$cat,'layout'=>5,)); break;
        case "layout_6" : weart_section( array('tag'=>$tag,'cat'=>$cat,'layout'=>6,'logo'=>1)); break;
        case "layout_7" : weart_section( array('layout'=>7,)); break;
        case "off" : break;
      }

    //banners
      if( $p[$i]['layout'] !== 'off' ){ weart_bannerHome($i); }

    }

if(!is_single()): get_footer(); endif; ?>