<?php
	$card = _ceo('card');
	if(!$card){
?>

<div class="ceo-container" >
	<div class="ceo-alert-primary" ceo-alert>
		<a class="ceo-alert-close" ceo-close></a>
		<p class="ceo-text-small"><i class="iconfont icon-warning-fill ceo-margin-small-right"></i>请前往后台<i class="iconfont icon-angle-right"></i>主题设置<i class="iconfont icon-angle-right"></i>首页设置<i class="iconfont icon-angle-right"></i>卡片列表，设置该模块内容！</p>
	</div>
</div>
<?php
	}else {
	if ($card) {
		foreach ( $card as $key => $value) {
		    global $ceo_width_4;
            $ceo_width_4='ceo-width-1-4';
            if(!empty($value['enable5col'])){
                $ceo_width_4='ceo-width-1-5';
            }
?>

<section class="card">
	<div class="ceo-container ceo-margin-medium-top ceo-margin-bottom-40">
		<div class="ceo-home-card section-title ceo-flex ceo-flex-middle">
		    <i class="iconfont <?php echo $card[$key]['icon']; ?> ceo-icon-index"></i>
			<h3 class="ceo-display-inline-block ceo-margin-remove">
				<?php
					if(!$value['title']){
						echo get_cat_name( $value['id'] );
					}else {
						echo $value['title'];
					}
				?>

			</h3>
			<div class="sub-nav ceo-flex-1 ceo-visible@s">
			    <ul class="ceo-text-small ceo-margin-remove ceo-padding-remove">
				<?php
                $display_cat_arr = ! empty($value['cat_id']) ? $value['cat_id'] : [];
                if($display_cat_arr){
                    foreach ($display_cat_arr as $v){
                        echo '<li class="cat-item cat-item-'.$v.'"><a href="'.get_category_link($v).'" title="'.get_cat_name($v).'">'.get_cat_name($v).'</a> </li>';
                    }
                }
				?>
				</ul>
			</div>
			<div class="sub-nav ceo-visible@s">
				<ul class="ceo-text-small ceo-margin-remove ceo-padding-remove">
					<li><span class="all ceo-display-inline-block"><a href="<?php echo get_category_link($value['id']); ?>" target="_blank" >查看更多<i class="iconfont icon-arrow-right"></i></a></span></li>
				</ul>
			</div>
		</div>
		<div class="card ceo-grid-medium ceo-home-card-top" ceo-grid>
			<?php query_posts('cat='.$value['id'] .'&showposts='.$value['num'] ); ?>
			<?php while (have_posts()) : the_post(); ?>
			    <?php
					$index_card_style = $value['index_card_style'];
					if( $index_card_style == 'card' ){ ?>
				<?php get_template_part( 'template-parts/home/loop', 'card_2' );?>

				<?php } elseif( $index_card_style == 'software' ) { ?>

				<?php get_template_part( 'template-parts/home/loop', 'software' );?>

				<?php } elseif( $index_card_style == 'album' ) { ?>

				<?php get_template_part( 'template-parts/home/loop', 'album' );?>
				
				<?php } elseif( $index_card_style == 'music' ) { ?>

				<?php get_template_part( 'template-parts/loop/loop', 'home_music' );?>
				
				<?php } elseif( $index_card_style == 'cardvideo' ) { ?>

				<?php get_template_part( 'template-parts/loop/loop', 'home_cardvideo' );?>
				
				<?php } elseif( $index_card_style == 'sucai' ) { ?>

				<?php get_template_part( 'template-parts/loop/loop', 'home_sucai' );?>

				<?php }else ?>
			<?php endwhile; wp_reset_query(); ?>

		</div>
	</div>
</section>
<?php } }  } ?>
