-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.php
90 lines (77 loc) · 2.51 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
<?php
/**
* Template part for displaying posts.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package Newspaper X
*/
$breadcrumbs_enabled = get_theme_mod( 'newspaper_x_enable_post_breadcrumbs', true );
if ( $breadcrumbs_enabled && is_single() ) {
Newspaper_X_Helper::add_breadcrumbs();
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<div class="newspaper-x-image">
<?php
$image = '<img class="wp-post-image" alt="" src="' . get_template_directory_uri() . '/assets/images/picture_placeholder.jpg" />';
if ( has_post_thumbnail() ) {
$image = is_single() ? get_the_post_thumbnail( get_the_ID(), 'newspaper-x-single-post' ) : get_the_post_thumbnail( get_the_ID(), 'newspaper-x-recent-post-big' );
}
$image_obj = array( 'id' => get_the_ID(), 'image' => $image );
$new_image = apply_filters( 'newspaper_x_widget_image', $image_obj );
$allowed_tags = array(
'img' => array(
'data-srcset' => true,
'data-src' => true,
'srcset' => true,
'sizes' => true,
'src' => true,
'class' => true,
'alt' => true,
'width' => true,
'height' => true
),
'noscript' => array()
);
echo ! is_single() ? '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' : '';
echo wp_kses( $new_image, $allowed_tags );
echo ! is_single() ? '</a>' : '';
?>
</div>
<?php
if ( ! is_single() ) {
echo '<h4 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . wp_trim_words( get_the_title(), 8 ) . '</a></h4>';
}
if ( 'post' === get_post_type() ) : ?>
<div class="newspaper-x-post-meta">
<?php Newspaper_X_Helper::posted_on(); ?>
</div><!-- .entry-meta -->
<?php
endif; ?>
<?php
if ( is_single() ) {
the_title( '<h2 class="entry-title">', '</h2>' );
}
?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php
if ( is_single() ) {
the_content();
} else {
echo '<p>' . wp_trim_words( wp_kses_post( get_the_content( esc_html__( 'Read More', 'newspaper-x' ) ) ), 35 ) . '</p>';
}
?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php
if ( is_single() ) {
// Include author information
get_template_part( 'template-parts/author-info' );
}
?>
</footer><!-- .entry-footer -->
<?php if ( is_single() ):do_action( 'newspaper_x_single_after_article' ); endif; ?>
</article><!-- #post-## -->