-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfront-page.php
48 lines (42 loc) · 1.11 KB
/
front-page.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
<?php
/**
* Front page
*
* @file front-page
* @package JVEB
* @author Jérémy Levron <[email protected]> (https://19h47.fr)
*/
use Timber\{ Timber, Helper };
use JVEB\{ Transients };
$context = Timber::get_context();
$context['posts'] = Helper::transient(
'jveb_front_page_posts_' . pll_current_language( 'slug' ),
function() {
return Timber::get_posts(
array(
'post_type' => 'post',
'posts_per_page' => 5,
'post__not_in' => get_option( 'sticky_posts' ),
'post_status' => 'publish',
'meta_query' => array( // phpcs:ignore
'relation' => 'OR',
array(
'key' => 'exclude_from_front_page',
'value' => '',
'compare' => 'NOT EXISTS',
),
array(
'key' => 'exclude_from_front_page',
'value' => '0',
'compare' => '==',
),
),
)
);
}
);
$context['per_page'] = 5;
$context['found_posts'] = Transients::front_page_posts_count();
$context['posts_on_front_page'] = get_option( 'posts_on_front_page' );
$templates = array( 'pages/front-page.html.twig' );
Timber::render( $templates, $context );