File: /www/wwwroot/www.sceybwg.com/wp-content/themes/Modular/template/module-page/theme-news.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-04-20 20:24:36
*/
if(!empty($module_content)){?>
<div class="section">
<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="<?php echo $wow_style;?> md-news">
<?php
//对应的分类文章
if( !empty($module_content) && count((array)$module_content)>1 ){
foreach ($module_content as $cat_id ){
$cat = get_category($cat_id['cat_id']);
echo '<div class="cat-item '.$module_setting['cat_style'].'">';
//分类标题
if( !empty($cat) ){
echo '<div class="cat-title">';
echo '<a href="'.get_category_link($cat_id['cat_id']).'"><h3>'.$cat->name.'</h3></a>';
echo '<a href="'.get_category_link($cat_id['cat_id']).'" class="more"><span>'.__( '查看更多', 'modular_theme' ).'</span><i class="ri-arrow-right-double-line"></i></a>';
echo '</div>';
}
//分类缩略图
if( !empty($cat_id['cat_img']) ){
echo '<div class="cat-img">';
echo '<a href="'.get_category_link($cat_id['cat_id']).'" aria-label="'.$cat->name.'">';
echo '<img loading="lazy" src="'.$cat_id['cat_img'].'" alt="'.dahuzi_get_image_alt($cat_id['cat_img']).'" />';
echo '</a>';
echo '</div>';
}
//文章列表
$cat_posts_query = wpjam_query([
'posts_per_page' => $module_setting['post_per_page'] ?: '6',
'ignore_sticky_posts' => true,
'cat' => $cat_id['cat_id']
]);
if($cat_posts_query->have_posts()){
if( !empty($module_setting['post_time']) ){
echo '<ul class="news-list">';
}else{
echo '<ul class="news-list no-time">';
}
while($cat_posts_query->have_posts()){
$cat_posts_query->the_post();
global $post;
echo '<li>';
echo '<a href="'.get_the_permalink().'">'.get_the_title().'</a>';
if( !empty($module_setting['post_time']) ){
echo '<span>'.get_the_date().'</span>';
}
echo '</li>';
}
wp_reset_query();
echo '</ul>';
}else{
echo '<p style="width:100%;text-align:center;">'.__( '暂无相关内容', 'modular_theme' ).'</p>';
}
echo '</div>';
}
}
?>
</div>
</div>
</div>
<?php }?>
<?php
//echo wpjam_print_r( $module_setting );
//echo wpjam_print_r( $module_content );
//echo wpjam_print_r( $module_style );