-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.php
More file actions
101 lines (94 loc) · 3.73 KB
/
Copy pathhome.php
File metadata and controls
101 lines (94 loc) · 3.73 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
<?php
/**
* Climate Hub Blog Page
*
* @package climatehub
*/
?>
<?php get_header(); ?>
<?php
$id = get_option('page_for_posts');
$title = get_field("enable_title", $id) && get_field("title", $id);
$paragraph = get_field("enable_paragraph", $id) && get_field("paragraph", $id);
if ($title || $paragraph): ?>
<div class="container">
<div class="row pt-5">
<div class="col-12">
<?php if($title): ?>
<h1 class="font-weight-bold pl-5"><?php the_field("title", $id); ?> </h1>
<?php endif; ?>
</div>
<div class="col-12 col-md-8 m-auto">
<?php if($paragraph): ?>
<?php the_field("paragraph", $id); ?>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php if (have_posts()): ?>
<div class="container mb-4">
<div class="row row">
<?php while (have_posts()): the_post(); ?>
<div class="col-12 col-md-6 col-lg-4 mt-4">
<a class="item d-flex bg-white justify-content-between text-body m-auto" target="<?php echo (get_field('post_behaviour') == 'link') ? get_field('post_link')['target'] : '_self'; ?>" href="<?php echo (get_field('post_behaviour') == 'link') ? get_field('post_link')['url'] : the_permalink() ?>">
<div class="blog-card-content">
<h4 class="font-weight-bold"><?php the_title() ?></h4>
<?php
if (have_rows('post_content')):
while (have_rows('post_content')): the_row();
if (get_row_layout() == 'header'):
echo '<p>' . strip_tags(get_sub_field('excerpt'), '<br><em><strong><b><i>') . '</p>';
endif;
endwhile;
endif;
?>
</div>
<?php if (get_the_post_thumbnail_url()):
$image_id = get_post_thumbnail_id();
$image_alt = get_post_meta($image_id, '_wp_attachment_image_alt', TRUE);
?>
<img class="blog-card-img" src="<?php echo get_the_post_thumbnail_url(); ?>" alt="<?php echo $image_alt; ?>"/>
<?php endif; ?>
</a>
</div>
<?php endwhile; ?>
</div>
<div class="row">
<div class="col-12">
<nav aria-label="Blog page navigation">
<?php
global $wp_query;
$current = max( 1, absint( get_query_var( 'paged' ) ) );
$pagination = paginate_links( array(
'base' => str_replace( PHP_INT_MAX, '%#%', esc_url( get_pagenum_link( PHP_INT_MAX ) ) ),
'format' => '?paged=%#%',
'current' => $current,
'total' => $wp_query->max_num_pages,
'type' => 'array',
'prev_text' => '«',
'next_text' => '»',
) ); ?>
<?php if ( ! empty( $pagination ) ) : ?>
<ul class="pagination justify-content-center mt-4 mb-0">
<?php if ( strpos(htmlspecialchars($pagination[0]), 'laquo') === false ) : ?>
<li class="page-item disabled">
<span class="page-numbers">«</span>
</li>
<?php endif; ?>
<?php foreach ( $pagination as $key => $page_link ) : ?>
<li class="page-item<?php if ( strpos( $page_link, 'current' ) !== false ) { echo ' active'; } ?>"><?php echo $page_link ?></li>
<?php endforeach; ?>
<?php if ( strpos(htmlspecialchars(end($pagination)), 'raquo') === false ) : ?>
<li class="page-item disabled">
<span class="page-numbers">»</span>
</li>
<?php endif; ?>
</ul>
<?php endif ?>
</nav>
</div>
</div>
</div>
<?php endif; ?>
<?php get_footer(); ?>