-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent.php
54 lines (45 loc) · 1.71 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
<?php
/**
* Template part for displaying posts.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package Envy Blog
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
$sidebar_class = envy_blog_layout_class();
if ( $sidebar_class == 'full-width' ) {
$img_size = 'envy-blog-1200-16x9';
} else {
$img_size = 'envy-blog-960-16x9';
}
$image_id = get_post_thumbnail_id();
$image_path = wp_get_attachment_image_src( $image_id, $img_size, true );
$image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
$alt = !empty( $image_alt ) ? $image_alt : the_title_attribute( 'echo=0' ) ;
?>
<?php if( has_post_thumbnail() ) : ?>
<figure>
<img src="<?php echo esc_url( $image_path[0] ); ?>" alt="<?php echo esc_attr( $alt ); ?>" title="<?php the_title_attribute(); ?>" />
</figure>
<?php endif; ?>
<div class="content-wrap">
<header class="entry-header">
<?php
the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php
$content = wp_trim_words( get_the_excerpt(), 18, '...' );
echo '<p>'.wp_kses_post( $content ).'</p>';
wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'envy-blog' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
</div><!-- .content-wrap -->
</article><!-- #post-## -->