File: /www/wwwroot/www.sceybwg.com/wp-content/themes/Modular/template/module-page/theme-case.php
<?php
/**
* Template: 案例展示
* @Author: 大胡子
* @Email: dahuzi@xintheme.com
* @Link: www.xintheme.com
* @Date: 2023-08-01 07:27:28
* @Last Modified by: dahuzi
* @Last Modified time: 2024-08-28 16:25:17
*/
if(!empty($module_content)){
// 限制图片高度
$post_thumb_pc_h = !empty($module_content['post_thumb_pc_h']) ? '--post_thumb_pc_h:' . intval($module_content['post_thumb_pc_h']) . 'px;' : '--post_thumb_pc_h:auto;';
$post_thumb_mb_h = !empty($module_content['post_thumb_mb_h']) ? '--post_thumb_mb_h:' . intval($module_content['post_thumb_mb_h']) . 'px;' : '--post_thumb_mb_h:auto;';
$post_thumb_h = ($post_thumb_pc_h || $post_thumb_mb_h) ? sprintf('style="%s%s"', $post_thumb_pc_h, $post_thumb_mb_h) : '';
?>
<div class="section" <?php echo $post_thumb_h; ?>>
<div class="container">
<?php
if( !empty($module_setting['title_display']) ){?>
<div class="section-title <?php echo $wow_style;?>">
<?php
if( !empty($module_title) ){
echo '<strong>'.$module_title.'</strong>';
}
if( !empty($module_desc) ){
echo '<p>'.$module_desc.'</p>';
}
?>
</div>
<?php
}
?>
<div class="swiper md-case <?php echo $wow_style;?><?php if( !empty($module_content['cat_pagination']) ){ echo ' show-pagination'; }?>">
<div class="swiper-wrapper">
<?php
//对应的分类文章
$cat_posts_query = wpjam_query([
'posts_per_page' => $module_content['post_per_page'] ?: '6',
'ignore_sticky_posts' => true,
'cat' => $module_content['cat_id']
]);
if($cat_posts_query->have_posts()){
while($cat_posts_query->have_posts()){
$cat_posts_query->the_post();
global $post;
//获取文章缩略图
$get_post_thumbnail_url = wpjam_get_post_thumbnail_url();
//图片Alt标签
//$img_alt = get_the_title();
?>
<div class="swiper-slide">
<div class="case-item">
<a href="<?php the_permalink(); ?>">
<div class="img-cover">
<img loading="lazy" src="<?php echo $get_post_thumbnail_url;?>" alt="<?php //secho $img_alt;?>" />
</div>
<div class="text">
<h2><?php the_title();?></h2>
<?php dahuzi_excerpt( 100, '...' );?>
</div>
</a>
</div>
</div>
<?php
}
wp_reset_query();
}else{
echo '<p style="width:100%;text-align:center;">'.__( '暂无相关内容', 'modular_theme' ).'</p>';
}
?>
</div>
</div>
<?php
//分页导航
if( !empty($module_content['cat_pagination']) ){
echo '<div class="swiper-pagination"></div>';
}
//切换按钮
if( !empty($module_content['cat_next_prev']) ){
echo '<div class="swiper-button-next"></div>';
echo '<div class="swiper-button-prev"></div>';
}
//查看更多
if( !empty($module_content['cat_url']) ){
echo '<div class="case-more">';
echo '<a href="'.get_category_link($module_content['cat_id']).'" class="cat-url">'.__( '查看更多', 'modular_theme' ).'</a>';
echo '</div>';
}?>
</div>
</div>
<?php }?>
<?php
//echo wpjam_print_r( $module_setting );
//echo wpjam_print_r( $module_content );
//echo wpjam_print_r( $module_style );