-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathhome.php
71 lines (56 loc) · 1.79 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
<?php
/**
* The template for displaying the blog home page.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Rosa2 Lite
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header();
$page_id = get_option( 'page_for_posts' ); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
$page_for_posts = get_option( 'page_for_posts' );
$categories = get_categories();
if ( ! empty( $categories ) ) {
$categories = array_filter( $categories, function ( $category ) {
return $category->term_id !== 1;
} );
}
$has_title = ! empty( $page_for_posts );
$has_categories = ! empty( $categories ) && ! is_wp_error( $categories );
if ( have_posts() ) {
if ( $has_title || $has_categories ) { ?>
<header class="entry-header">
<div class="entry-content has-text-align-center">
<?php
if ( $has_title ) {
echo '<h1 class="page-title">' . get_the_title( $page_id ) . '</h1>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ( $has_categories ) {
echo '<ul class="entry-meta">';
foreach ( $categories as $category ) {
$category_url = get_category_link( $category->term_id );
echo '<li><a href="' . esc_url( $category_url ) . '">' . esc_html( $category->name ) . '</a></li>';
}
echo '</ul>';
} ?>
</div>
</header><!-- .page-header -->
<?php } ?>
<div class="entry-content">
<?php
get_template_part( 'template-parts/loop' );
rosa2_lite_the_posts_pagination(); ?>
</div>
<?php } else {
get_template_part( 'template-parts/content', 'none' );
} ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_footer();