File: /www/wwwroot/www.scdc-marine.com/wp-content/themes/scdc-marine/TempParts/Single/single-news.php
<?php
use Heku\HekuClass\View\News;
/**
* 新闻详情页
*/
$custom_viewer_inline_script = '
window.addEventListener("DOMContentLoaded", function () {
var single_info_galley = document.getElementById("single_info_content");
var single_info_viewer = new Viewer(single_info_galley, {
url: "src",
toolbar:{
oneToOne: false,
play: false,
prev: function() {
single_info_viewer.prev(true);
},
next: function() {
single_info_viewer.next(true);
},
},
title:false,
});
});';
wp_enqueue_script( 'heku-viewer', HEKU_THEME_URI . '/Assets/js/viewer.min.js' );
wp_add_inline_script( 'heku-viewer', $custom_viewer_inline_script, 'after' );
//the_content();
add_action('heku_footer_inline_js','footer_inline_js_html', 10);
function footer_inline_js_html(){
wp_print_scripts('heku-viewer');
}
$product_posts = get_post_meta( get_the_ID(), 'product_hot_post', true );
$product_news = get_post_meta( get_the_ID(), 'product_related_news', true );
?>
<!-- / star heku_top -->
<?php get_template_part( "TempParts/Main/TopMenu/top_menu"); ?>
<?php get_template_part( "TempParts/Main/TopBanner/top_banner"); ?>
<!-- / end heku_top -->
<!-- / star single_bar_line -->
<?php get_template_part("TempParts/Main/Breadcrumb/breadcrumb"); ?>
<!-- / end single_bar_line -->
<div id="single_main_line">
<div class="container clearfix">
<div class="row no-gutters">
<div class="single-sidebar order-xl-first d-xl-block d-none sidebar-right mr-xl-4 clearfix ">
<!-- / star single_bar_line -->
<?php get_template_part("TempParts/Main/Sidebar/sidebar"); ?>
<!-- / end single_bar_line -->
</div>
<div class="single-main col ml-xl-2">
<div class="single-info heku-box no-gutters wow slideInRight" >
<div class="single-title"><?php echo get_the_title(); ?></div>
<div class="single-meta-row pt-3 pb-2 d-flex justify-content-between">
<ul class="single-meta-box">
<li class="single-date"><span class="icon iconfont icon-time-3"></span><?php echo date('F',get_the_time('U')) . ' ' . get_the_time(' jS Y'); ?></li>
<li class="single-eye"><span class="icon iconfont icon-a-13"></span><span><?php if(function_exists('the_views')) { the_views(); } ?> Views</span></li>
</ul>
<ul class="single-tags-box">
<?php
if (is_single()){
$tags = wp_get_post_tags(get_the_id());
$i = 0;
foreach ($tags as $tag ) {
$posts = get_posts( ['fields' => 'ids','posts_per_page' => -1,'post_type' => 'post','tax_query' => [['taxonomy' => 'post_tag','field'=> 'id','terms'=> $tag->term_taxonomy_id,],],] );
$thumb_url = "/tag/" . $tag->slug;
if( isset( $posts[0] ) &&( count($posts) == 1 ) ){
$thumb_url = get_permalink($posts[0]);
}
if( $i++ < 2 ){ ?>
<li class="single-tags-item" ><span class="icon iconfont icon-a-12"></span><a target="_blank" href="<?php echo $thumb_url; ?>"><?php echo $tag->name; ?></a></li>
<?php }
}
} ?>
</ul>
</div>
<div id="single_info_content" >
<div class="entry-content pt-2 pb-2">
<?php the_content(); ?>
<ul class="single-tags-box pt-2">
<?php
if (is_single()){
$tags = wp_get_post_tags(get_the_id());
$i = 0;
foreach ($tags as $tag ) {
$posts = get_posts( ['fields' => 'ids','posts_per_page' => -1,'post_type' => 'post','tax_query' => [['taxonomy' => 'post_tag','field'=> 'id','terms'=> $tag->term_taxonomy_id,],],] );
$thumb_url = "/tag/" . $tag->slug;
if( isset( $posts[0] ) &&( count($posts) == 1 ) ){
$thumb_url = get_permalink($posts[0]);
}
if( $i++ < 4 && $i > 1){ ?>
<li class="single-tags-item" ><span class="icon iconfont icon-a-12"></span><a target="_blank" href="<?php echo $thumb_url; ?>"><?php echo $tag->name; ?></a></li>
<?php }
}
} ?>
</ul>
</div>
</div>
</div>
<?php if( isset( $product_posts[0] ) && ( count($product_posts) > 0 ) ){ ?>
<div class="single-title hekutitle01 pt-2 pb-3 wow fadeInUp">
Hot Sales Products
</div>
<ul class="row product-box product-box-1 ">
<!-- end heku-top-menu -->
<?php foreach( $product_posts as $post): ?>
<?php setup_postdata($post); ?>
<?php get_template_part("TempParts/Main/item-Template/item-product2"); ?>
<?php endforeach; ?>
<!-- end heku-top-menu -->
</ul>
<?php wp_reset_postdata();
} ?>
<?php if( isset( $product_news[0] ) && ( count($product_news) > 0 ) ){ ?>
<div class="single-title hekutitle01 pt-3 pb-3 wow fadeInUp">
Related News & Service
</div>
<ul class="news-box news-box-1 archive-news pb-3 row">
<?php foreach( $product_news as $post): ?>
<?php setup_postdata($post); ?>
<?php get_template_part("TempParts/Main/item-Template/item-news-1"); ?>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata();
} ?>
</div>
</div>
</div>
</div>