-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle.php
More file actions
109 lines (77 loc) · 4.2 KB
/
single.php
File metadata and controls
109 lines (77 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* Single Post template
*/
$external_url = get_field('post_external_url');
if ( $external_url ) {
wp_redirect( $external_url );
}
get_header();
global $post;
$cats = get_the_terms( $post, 'category' );
$cat = ( ! empty( $cats ) ) ? $cats[0]->name : 'News';
$post_datetime = get_field( 'post_datetime' );
$post_datetime = ( $post_datetime ) ? $post_datetime : strtotime( $post->post_date );
$video_url = get_field('featured_video_url'); ?>
<div class="site-content">
<?php while ( have_posts() ) : the_post(); ?>
<article <?php post_class('wrap'); ?>>
<section class="section">
<div class="flex has-sidebar u-container">
<?php get_template_part( 'partials/menu-ui' ); ?>
<div class="sidebar-masthead section__sidebar flex__item">
<?php get_template_part( 'partials/masthead' ); ?>
</div>
<div class="section__content flex__item">
<div class="page-header">
<div class="h2 u-mt-pull"><?php echo $cat; ?></div>
</div>
<h1 class="post-title u-mt-3">
<?php the_title(); ?>
</h1>
<h2 class="h3 u-mt-nudge"><?php echo date( get_option( 'date_format' ), $post_datetime ); ?></h2>
<?php if ( $video_url ) : ?>
<div class="hsc-video u-mt-3 video--preload js-hsc-video" data-url="<?php echo $video_url; ?>" data-callback="removeBadge">
<?php the_post_thumbnail( 'large', array( 'class' => 'u-display-block' ) ); ?>
<div class="hsc-video__play"><?php get_template_part( 'partials/play-icon' ); ?></div>
</div>
<?php else : ?>
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-image u-mt-3">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="post-content u-mt-2">
<?php the_content(); ?>
</div>
</div>
</div><!-- .u-container -->
</section>
<!--Related Posts-->
<?php
$args = array(
'posts_per_page' => 2,
'post__not_in' => array( $post->ID ),
);
$recent = new WP_Query( $args ); ?>
<?php if ( $recent->have_posts() ) : ?>
<section class="section">
<div class="flex u-container">
<div class="section__content flex__item u-width-12">
<div class="h6 u-mt-0"><?php _e( 'Recent News', 'hsc' ); ?></div>
<ul class="u-clearfix">
<?php while( $recent->have_posts() ) : $recent->the_post(); ?>
<li class="u-span-6">
<?php get_template_part( 'partials/content-preview', 'post' ) ?>
</li>
<?php endwhile; ?>
</ul>
</div>
</div><!-- .u-container -->
</section>
<?php endif; ?>
</article>
<?php endwhile; ?>
</div>
<?php get_footer(); ?>