This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
home.php
83 lines (73 loc) · 2.82 KB
/
home.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
<?php
/**
* The home/blog template file.
*
* @package Briar
* @since 1.0
*/
global $allowedposttags;
get_header(); ?>
<div class="featured-hero">
<div class="container">
<div class="row">
<div class="col-lg-7">
<h2 class="featured-hero__title"><?php echo esc_html( get_bloginfo( 'description' ) ); ?></h2>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container -->
</div><!-- /.featured-hero -->
<div class="container">
<div class="row">
<div class="<?php briar_main_class(); ?>">
<div class="post-list" id="content" role="main">
<?php
$sticky_posts = get_option( 'sticky_posts' );
$sticky_post_id = ! empty( $sticky_posts ) ? $sticky_posts[0] : 0;
if ( ! empty( $sticky_posts ) && 1 === (int) max( 1, get_query_var( 'paged' ) ) ) :
$sticky_post = get_post( $sticky_post_id );
if ( ! empty( $sticky_post ) ) :
$image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $sticky_post_id ), 'briar-featured-image' );
$permalink = get_permalink( $sticky_post_id );
$content = strip_tags( strlen( $sticky_post->post_excerpt ) > 0 ? $sticky_post->post_excerpt : $sticky_post->post_content );
if ( strlen( $content ) > 140 ) {
$content = substr( $content, 0, 140 ) . '...';
}
?>
<div class="row">
<div <?php post_class( array( 'post-item', 'clearfix' ), $sticky_post_id ); ?>>
<div class="col-lg-12">
<a href="<?php echo esc_url( $permalink ); ?>">
<div class="post-item__img"<?php if ( ! empty( $image_url ) ) : ?> style="<?php echo esc_attr( 'background-image: url(' . $image_url[0] . ');' ); ?>"<?php endif; ?>>
<div class="post-item__overlay"></div><!-- /.overlay -->
<div class="post-item__content clearfix">
<h3 class="post-item__title"><?php echo get_the_title( $sticky_post ); ?></h3>
<?php if ( ! empty( $content ) ) : ?>
<p><?php echo wp_kses( $content, $allowedposttags ); ?></p>
<?php printf( '<div class="post-item__btn btn--transition">%s</div>', sprintf( esc_html__( 'Read more%s', 'briar' ), '<span class="screen-reader-text"> ' . get_the_title() . '</span>' ) ); ?>
<?php endif; ?>
</div><!-- /.content -->
</div>
</a>
</div><!-- /.col -->
</div><!-- /.news-block -->
</div><!-- /.row -->
<?php endif;
endif; ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
if ( get_the_id() !== $sticky_post_id ) {
get_template_part( 'content', get_post_format() );
}
?>
<?php endwhile; ?>
<?php briar_pagination(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</div>
</div>
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer();