File: /www/wwwroot/www.sceycy.com/wp-content/themes/Zing-Pro/single/single-grid.php
<?php
get_header();
$category = get_the_category();
if($category[0]){
$catid = $category[0]->term_id;
}
$category_data = get_term_meta( $catid, '_prefix_taxonomy_options', true );
$cat_banner_img = isset( $category_data['cat_banner_img']['url'] ) ? $category_data['cat_banner_img']['url'] : '';
$post_extend = get_post_meta( get_the_ID(), 'extend_info', true );
$no_sidebar = isset($post_extend['no_sidebar']) ?$post_extend['no_sidebar'] : '';
$post_header_banner = xintheme('post_header_banner');
$no_sidebar_all = xintheme('post_no_sidebar_all');
$single_ad = xintheme('single_ad');?>
<?php while( have_posts() ): the_post(); ?>
<?php if( $cat_banner_img && !$post_header_banner ){?>
<div class="module-default">
<div class="responsive-carousel carousel clearfix">
<div class="carousel-item">
<img loading="lazy" src="<?php echo $cat_banner_img;?>">
</div>
</div>
</div>
<?php }?>
<section class="main">
<div class="page-width clearfix">
<section class="content float-right<?php if( $no_sidebar==true || $no_sidebar_all ) : ?> no_sidebar<?php endif;?>">
<div class="breadcrumbs">
<?php if (function_exists('get_breadcrumbs')){get_breadcrumbs(); } ?>
</div>
<div class="content-box">
<div class="article-detail">
<div class="showDetailMain clearfloat">
<div class="showWap">
<div class="showPic">
<ul id="produc-slider" class="showSlider">
<?php
$post_meta = get_post_meta(get_the_ID(), 'extend_info', true);
$produc_img = isset($post_meta['produc_img']) ?$post_meta['produc_img'] : '';
?>
<?php
if($produc_img){
if( !empty( $produc_img ) ) :
$produc_img = explode( ',', $post_meta['produc_img'] );
foreach ( $produc_img as $id ) :
$produc_img_src = wp_get_attachment_image_src( $id, 'full' );
?>
<li>
<img loading="lazy" src="<?php echo $produc_img_src[0];?>" alt="<?php the_title(); ?>"/>
</li>
<?php endforeach;endif ?>
<?php }else{?>
<li>
<img loading="lazy" src="<?php echo post_thumbnail(500, 500); ?>" alt="<?php the_title(); ?>"/>
</li>
<?php }?>
</ul>
</div>
</div>
<div class="showDetailMainCont">
<h1><?php the_title_attribute(); ?></h1>
<div class="product-meta">
<span>
<i class="fa fa-folder"></i> <?php the_category(', ') ?>
</span>
<?php if( xintheme('xintheme_single_time') ){ ?>
<span class="productline">|</span>
<span>
<i class="fa fa-calendar"></i> <?php echo dahuzi_post_time();?>
<?php //echo get_the_date('Y-m-d H:i'); ?>
</span>
<?php }?>
<?php //if( xintheme('xintheme_single_views') ){ ?>
<!--span>
<strong><?php //post_views('',''); ?> 次浏览</strong>
</span-->
<?php //}?>
</div>
<?php
$produc_abstract = isset($post_meta['produc_abstract']) ?$post_meta['produc_abstract'] : '';
if($produc_abstract){
echo wpautop( $produc_abstract );
}else{
echo '<p>'.mb_strimwidth(strip_tags($post->post_content),0,200,'...').'</p>';
}
?>
<div class="showDetailMainB clearfloat">
<?php
$post_add_button = isset($post_meta['add_button']) ?$post_meta['add_button'] : '';
if($post_add_button){
$add_button = $post_add_button;
}else{
$add_button = xintheme('add_button');
}
if(is_array($add_button)){
foreach ( $add_button as $value ): ?>
<?php if( $value['produc_button_type'] == 'link' ){?>
<a href="<?php echo $value['button_url'];?>" rel="nofollow" target="_blank"<?php if( $value['button_color'] ){?> style="border: 1px solid <?php echo $value['button_color']?>;color:<?php echo $value['button_color']?>;"<?php }?>>
<?php if( $value['button_icon'] ){?><i class="<?php echo $value['button_icon'];?>"></i><?php }?> <?php echo $value['button_title'];?>
</a>
<?php }elseif( $value['produc_button_type'] == 'img' ){
$md5_title = 'a'.md5( $value['button_title'] );
?>
<a id="button_img" class="button_img" data-fancybox href="#<?php echo $md5_title;?>"<?php if( $value['button_color'] ){?> style="border: 1px solid <?php echo $value['button_color']?>;color:<?php echo $value['button_color']?>;"<?php }?>><?php if( $value['button_icon'] ){?><i class="<?php echo $value['button_icon'];?>"></i><?php }?> <?php echo $value['button_title'];?></a>
<div id="<?php echo $md5_title;?>" style="display:none;">
<a href="<?php echo $value['button_img']['url'];?>" target="_blank">
<img loading="lazy" src="<?php echo $value['button_img']['url'];?>" alt=" <?php echo $value['button_title'];?>">
</a>
<p style="text-align:center;font-size:16px;color:#333"><?php echo $value['button_title'];?></p>
</div>
<?php }else{?>
<a href="<?php if( wp_is_mobile() ){?>mqqwpa://im/chat?chat_type=wpa&uin=<?php echo $value['button_qq'];?>&version=1&src_type=web&web_src=oicqzone.com<?php }else{?>http://wpa.qq.com/msgrd?v=3&uin=<?php echo $value['button_qq'];?>&site=qq&menu=yes<?php }?>" rel="nofollow" target="_blank"<?php if( $value['button_color'] ){?> style="border: 1px solid <?php echo $value['button_color']?>;color:<?php echo $value['button_color']?>;"<?php }?>>
<?php if( $value['button_icon'] ){?><i class="<?php echo $value['button_icon'];?>"></i><?php }?> <?php echo $value['button_title'];?>
</a>
<?php }?>
<?php endforeach;?>
<?php }?>
</div>
</div>
</div>
<div class="article-content-wrapper">
<div class="article-content">
<div class="qhd-content" id="wzzt">
<?php if( !empty($single_ad['single_ad_top']['url']) ){?>
<div class="single-top">
<a href="<?php echo $single_ad['single_ad_top_url'];?>" target="_blank" rel="nofollow">
<img loading="lazy" src="<?php echo $single_ad['single_ad_top']['url'];?>" alt="<?php echo $single_ad['single_ad_top']['title'];?>">
</a>
</div>
<?php }?>
<?php the_content(); ?>
<div class="entry-tags">
<?php the_tags(__('Tags: ', 'dahuzi_theme'), ' · ', ''); ?>
</div>
<?php if( !empty($single_ad['single_ad_bottom']['url']) ){?>
<div class="single-bottom">
<a href="<?php echo $single_ad['single_ad_bottom_url'];?>" target="_blank" rel="nofollow">
<img loading="lazy" src="<?php echo $single_ad['single_ad_bottom']['url'];?>" alt="<?php echo $single_ad['single_ad_bottom']['title'];?>">
</a>
</div>
<?php }?>
</div>
</div>
<?php endwhile; ?>
<?php if( xintheme('xintheme_single_share') ){?>
<div class="detail-bottom">
<div class="share-links-wrap">
<p class="text-header small"><?php esc_html_e( 'Share: ', 'dahuzi_theme' ); ?></p>
<ul class="share-links hoverable">
<?php
if( get_locale() != 'zh_CN' ){
$links = dahuzi_sharing_links();
$options = xintheme( 'dahuzi_sharing_links', array( 'facebook', 'twitter', 'pinterest', 'linkedin', 'whatsapp' ) );
foreach ( $options as $option ) : ?>
<li><a class="<?php echo esc_attr( $option ); ?>" href="<?php echo esc_attr( $links[ $option ]['link'] ); ?>" target="_blank">
<i class="fa fa-<?php echo esc_attr( $links[ $option ]['icon'] ); ?>"></i>
</a></li>
<?php
endforeach;
}else{
$post_image = post_thumbnail(260, 260);
$qrcode = ''.get_bloginfo('template_directory').'/public/qrcode?data='.get_the_permalink().'';
echo '<li><a class="qq-share" href="' . esc_url(get_permalink()) . '" title="分享到QQ" data-title="' . esc_attr(get_the_title()) . '" data-image="' . esc_attr($post_image) . '" data-excerpt="'. get_the_excerpt() .'"><i class="iconfont icon-QQ"></i></a></li>';
echo '<li><a class="weixin-share" href="' . $qrcode . '" title="分享到微信" data-image="' . esc_attr($post_image) . '"><i class="iconfont icon-weixin"></i></a></li>';
echo '<li><a class="weibo-share" href="' . esc_url(get_permalink()) . '" title="分享到新浪微博" data-title="' . esc_attr(get_the_title()) . '" data-image="' . esc_attr($post_image) . '" data-excerpt="'. get_the_excerpt() .'"><i class="iconfont icon-weibo"></i></a></li>';
}?>
</ul>
</div>
</div>
<?php }?>
</div>
</div>
</div>
<?php if( xintheme('xintheme_single_prev') ){ //判断是否开启上一篇下一篇 开始?>
<div class="entry-page">
<?php //获取同分类下的上一篇 下一篇
$categories = get_the_category();
$categoryIDS = array();
foreach ($categories as $category) {
array_push($categoryIDS, $category->term_id);
}
$categoryIDS = implode(",", $categoryIDS);
?>
<?php
$prev_post = get_previous_post( $categoryIDS );
if(!empty($prev_post)):?>
<div class="entry-page-prev">
<a href="<?php echo get_permalink($prev_post->ID);?>" title="<?php echo $prev_post->post_title;?>"><span><?php echo $prev_post->post_title;?></span></a>
<div class="entry-page-info">
<span class="pull-left">« <?php esc_html_e( 'Previous post', 'dahuzi_theme' ); ?></span>
<span class="pull-right"><?php echo dahuzi_post_time();?></span>
</div>
</div>
<?php endif;?>
<?php
$next_post = get_next_post( $categoryIDS );
if(!empty($next_post)):?>
<div class="entry-page-next">
<a href="<?php echo get_permalink($next_post->ID);?>" title="<?php echo $next_post->post_title;?>"><span><?php echo $next_post->post_title;?></span></a>
<div class="entry-page-info">
<span class="pull-right"><?php esc_html_e( 'Next post', 'dahuzi_theme' ); ?> »</span>
<span class="pull-left"><?php echo dahuzi_post_time();?></span>
</div>
</div>
<?php endif;?>
</div>
<?php } //判断是否开启上一篇下一篇 结束?>
<?php if( dahuzi('post_contact') ){
get_template_part( 'template-parts/dahuzi_contact');
}?>
<?php if( xintheme('xintheme_single_comments') ){
comments_template( '', true );
}?>
<?php if( xintheme('xintheme_single_related') ){?>
<div class="related">
<h2><span><?php esc_html_e( 'Related Posts', 'dahuzi_theme' ); ?></span></h2>
<ul class="row2-svar clearfix">
<?php
$post_num = 8;
$exclude_id = $post->ID;
$posttags = get_the_tags(); $i = 0;
if ( $posttags ) {
$tags = '';
foreach ( $posttags as $tag ) $tags .= $tag->term_id . ',';
$args = array(
'post_status' => 'publish',
'tag__in' => explode(',', $tags),
'post__not_in' => explode(',', $exclude_id),
'ignore_sticky_posts' => 1,
'orderby' => 'comment_date',
'showposts' => $post_num
);
query_posts($args);
while( have_posts() ) { the_post(); ?>
<li class="col-4-1 fadeInUp not-animated"<?php echo data_animate();?>>
<div class="product-item">
<div class="portfolio-img">
<a href="<?php the_permalink(); ?>">
<img loading="lazy" src="<?php echo post_thumbnail(300, 300); ?>">
</a>
</div>
<div class="portfolio-title">
<h2><a href="<?php the_permalink(); ?>"><?php the_title_attribute(); ?></a></h2>
</div>
</div>
</li>
<?php
$exclude_id .= ',' . $post->ID; $i ++;
}
wp_reset_query();
}
if ( $i < $post_num ) {
$cats = ''; foreach ( get_the_category() as $cat ) $cats .= $cat->cat_ID . ',';
$args = array(
'category__in' => explode(',', $cats),
'post__not_in' => explode(',', $exclude_id),
'ignore_sticky_posts' => 1,
'orderby' => 'comment_date',
'showposts' => $post_num - $i
);
query_posts($args);
while( have_posts() ) {the_post(); ?>
<li class="col-4-1 fadeInUp not-animated"<?php echo data_animate();?>>
<div class="product-item">
<div class="portfolio-img">
<a href="<?php the_permalink(); ?>">
<img loading="lazy" src="<?php echo post_thumbnail(300, 300); ?>">
</a>
</div>
<div class="portfolio-title">
<h2><a href="<?php the_permalink(); ?>"><?php the_title_attribute(); ?></a></h2>
</div>
</div>
</li>
<?php
$i++; }
wp_reset_query();
}
//if ( $i == 0 ) echo '<li>暂无相关文章!</li>';
?>
</ul>
</div>
<?php }?>
</section>
<?php if( $no_sidebar==false && $no_sidebar_all==false ) : get_sidebar(); endif;?>
</div>
</section>
<?php get_footer(); ?>