-
Notifications
You must be signed in to change notification settings - Fork 1
/
content.php
110 lines (102 loc) · 4.24 KB
/
content.php
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
110
<?php
/**
* The default template for displaying content
*
* Used for both single and index/archive/search.
*
* @package WordPress
* @subpackage Nickel
* @since Nickel 1.0
*/
global $nickel_article_width;
$background = '';
if ( !is_single() ) {
$img = wp_get_attachment_image_src( get_post_thumbnail_id(), 'nickel-latest-news' );
$post_class = 'not-single-post';
$header_class = 'simple';
if ( !empty($img) ) {
$background = ' style="background: url(' . esc_url($img['0']) . ') no-repeat;"';
} else {
$background = ' data-noimage="true"';
}
} else {
$post_class = 'single-post';
$header_class = '';
}
$comments = wp_count_comments( get_the_ID() );
$comment_count = $comments->approved;
$categories = get_the_category( get_the_ID() );
$cat_list = array();
if ( !empty( $categories ) ) {
foreach ($categories as $cat_value) {
$cat_list[] = $cat_value->name;
}
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class($nickel_article_width.$post_class); echo $background; ?>>
<header class="entry-header <?php echo esc_attr($header_class); ?>">
<?php
if ( !is_single() && ( is_home() || is_archive() || is_search() ) ) {
echo '<div class="post-date">' . get_the_date( get_option( 'date_format' ), get_the_ID() ) . '</div>';
echo '<div class="clearfix"></div>';
the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
echo '</header><!-- .entry-header -->';
} elseif ( is_single() && !is_home() ) {
echo '</header><!-- .entry-header -->';
$img = wp_get_attachment_image_src( get_post_thumbnail_id(), 'nickel-full-width' );
if ( !empty($img) ) {
echo '<div class="single-post-image-container">';
echo '<img src="'.esc_url($img['0']).'" class="single-post-image" alt="Post with image">';
echo '<span class="single-post-category">' . implode($cat_list, ', ') . '</span>';
echo '</div>';
}
the_title( '<h1 class="entry-title">', '</h1>' );
}
?>
<?php if ( !is_single() && ( is_home() || is_archive() || is_search() ) ) : ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php echo '<a href="' . get_the_permalink() . '" class="single-read-more">' . esc_html__('Read more', 'nickel') . '</a>'; ?>
<?php echo '<span class="post-comments icon-comment-1"><a href="' . get_the_permalink() . '#comments">' . $comment_count . '</a></span>'; ?>
<?php else : ?>
<div class="entry-content">
<div id="entry-content-wrapper">
<?php the_content( esc_html__( 'Continue reading <span class="meta-nav">→</span>', 'nickel' ) ); ?>
</div>
<?php
wp_link_pages( array(
'before' => '<div class="page-links"><span class="page-links-title">' . esc_html__( 'Pages:', 'nickel' ) . '</span>',
'after' => '<div class="clearfix"></div></div>',
'link_before' => '<span>',
'link_after' => '</span>',
) );
?>
<div class="entry-content-meta">
<?php
nickel_post_category_list( get_the_ID() );
nickel_post_tag_list( get_the_ID() );
?>
<span class="entry-content-date icon-calendar"><?php echo get_the_date( get_option( 'date_format' ), get_the_ID() ); ?></span>
<span class="entry-content-time icon-clock"><?php echo human_time_diff(get_the_time('U',get_the_ID()),current_time('timestamp')) . ' '.esc_html__('ago', 'nickel'); ?></span>
</div>
<?php if ( function_exists('nickel_get_content_share') ) { echo nickel_get_content_share(); } ?>
<?php nickel_prev_next_links(); ?>
<?php if ( get_the_author_meta( 'description' ) ) { ?>
<div id="author-info">
<h4 class="author-title"><?php esc_html_e('About post author', 'nickel'); ?></h4>
<div class="author-infobox">
<div id="author-avatar">
<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'vh_author_bio_avatar_size', 120 ) ); ?>
</div>
<div id="author-description">
<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author"><?php echo get_the_author(); ?></a>
<p><?php the_author_meta( 'description' ); ?></p>
</div><!-- end of author-description -->
</div>
<div class="clearfix"></div>
</div><!-- end of entry-author-info -->
<?php } ?>
</div><!-- .entry-content -->
<?php endif; ?>
</article><!-- #post-## -->