-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhome.php
168 lines (143 loc) · 5.1 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
/**
* Template Name: Home
*
* The template for displaying the footer
*
* Contains the closing of the #content div and all content after.
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package topolitik
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<!-- NEW Section 1 -->
<div class="layout-container">
<div class="homepage-section">
<div class="homepage-section-margin latest">
<div class="homepage-section-latest-presentation">
<h1 class="homepage-section-title no-mobile"><?php echo get_theme_mod('homepage_section_1_header') ?></h1>
<p class="homepage-section-description no-mobile"><?php echo get_theme_mod('homepage_section_1_body') ?></p>
</div>
</div>
<div class="homepage-section-content">
<div class="homepage-section-content-first-articles">
<?php
$latest_blog_posts = new WP_Query( array( 'posts_per_page' => 5, 'cat' => '-593' ) );
if ( $latest_blog_posts->have_posts() ) {
while ( $latest_blog_posts->have_posts() ) {
$latest_blog_posts->the_post();
$isVideo = false;
$show = true;
$categories = wp_get_post_categories($post_id=get_the_ID());
foreach ($categories as $cat) {
// code...
echo ' ';
if (get_cat_name($cat)=="TV") {
$isVideo = true;
}
}
set_query_var( 'archive_type', 'home' );
get_template_part( 'template-parts/article-card', get_post_type() );
if ($latest_blog_posts->current_post === 1) {
// add div after first post
echo '</div><div class="homepage-section-content-last-articles">';
}
}
}
?>
</div><!-- .homepage-section-content-last-articles -->
</div><!-- .homepage-section-content -->
</div><!-- .homepage-section -->
</div><!-- .section-container -->
<!-- NEW Section 1 -->
<!-- NEW Section 2 - Dossiers -->
<div class="layout-container">
<div class="homepage-section">
<div class="homepage-section-margin latest">
<div class="homepage-section-latest-presentation">
<h1 class="homepage-section-title no-mobile">Dossiers</h1>
<p class="homepage-section-description no-mobile">
Explorez nos series d'articles concoctés rien que pour vous.
</p>
</div>
</div>
<div class="homepage-section-content">
<div class="homepage-section-content-first-articles">
<?php
$dossiers = new WP_Query(array(
'posts_per_page' => 5,
'post_type' => 'dossier',
'orderby' => 'post_date', // Order by date
));
if ( $dossiers->have_posts() ) {
while ( $dossiers->have_posts() ) {
$dossiers->the_post();
?>
<div class="home-dossier-container">
<?php get_template_part( 'template-parts/dossier-card' ); ?>
</div>
<?php
}
}
?>
</div><!-- .homepage-section-content-last-articles -->
</div><!-- .homepage-section-content -->
</div><!-- .homepage-section -->
</div><!-- .section-container -->
<!-- NEW Section 2 -->
<!-- NEW Sections 2 to 5 -->
<?php
foreach (range(2, 8) as $section_number):
$category = null;
$category = get_theme_mod('homepage_section_'.$section_number);
if ($category):
$categoryObj = get_category_by_slug($category);
?>
<div class="layout-container">
<div class="homepage-section">
<div class="homepage-section-margin">
<h1 class="homepage-section-title"><?php echo $categoryObj->name ?></h1>
<p class="homepage-section-description"><?php echo $categoryObj->description ?></p>
<a target="_blank" href="<?php echo esc_url(get_category_link($categoryObj->term_id))?>">Plus d'articles</a>
<p><?php echo $categoryObj->count ?> articles</p>
</div>
<div class="homepage-section-content">
<div class="homepage-section-content-first-articles">
<?php
$latest_blog_posts = new WP_Query( array( 'posts_per_page' => 5, 'category_name'=> $category, 'cat' => '-593' ) );
if ( $latest_blog_posts->have_posts() ) {
while ( $latest_blog_posts->have_posts() ) {
$latest_blog_posts->the_post();
$isVideo = false;
$show = true;
$categories = wp_get_post_categories($post_id=get_the_ID());
foreach ($categories as $cat) {
// code...
echo ' ';
if (get_cat_name($cat)=="TV") {
$isVideo = true;
}
}
get_template_part( 'template-parts/article-card', get_post_type() );
if ($latest_blog_posts->current_post === 1) {
// add div after first post
echo '</div><div class="homepage-section-content-last-articles">';
}
}
}
?>
</div><!-- .homepage-section-content-last-articles -->
</div><!-- .homepage-section-content-->
</div><!-- .homepage-section -->
</div><!-- .section-container -->
<?php endif;endforeach; ?>
<!-- NEW Sections 2 to 5 -->
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();