This repository has been archived by the owner on Aug 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfront-page.php
executable file
·128 lines (107 loc) · 3.35 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
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
<?php
/**
* Front page for the Utility Pro theme
*
* @package Utility_Pro
* @author Carrie Dils
* @license GPL-2.0+
*
*/
add_action( 'genesis_meta', 'utility_pro_homepage_setup' );
/**
* Set up the homepage layout by conditionally loading sections when widgets
* are active.
*
* @since 1.0.0
*/
function utility_pro_homepage_setup() {
$home_sidebars = array(
'home_welcome' => is_active_sidebar( 'utility-home-welcome' ),
'home_gallery_1' => is_active_sidebar( 'utility-home-gallery-1' ),
'call_to_action' => is_active_sidebar( 'utility-call-to-action' ),
);
// Return early if no sidebars are active
if ( ! in_array( true, $home_sidebars ) ) {
return;
}
// Get static home page number.
$page = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
// Only show home page widgets on page 1.
if ( 1 == $page ) {
// Add home welcome area if "Home Welcome" widget area is active
if ( $home_sidebars['home_welcome'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_welcome' );
}
// Add home gallery area if "Home Gallery 1" widget area is active
if ( $home_sidebars['home_gallery_1'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_gallery' );
}
// Add call to action area if "Call to Action" widget area is active
if ( $home_sidebars['call_to_action'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_call_to_action' );
}
}
// Remove standard loop and replace with loop showing Posts, not Page content.
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action ( 'genesis_loop', 'utility_pro_front_loop' );
}
// Display content for the "Home Welcome" section
function utility_pro_add_home_welcome() {
genesis_widget_area( 'utility-home-welcome',
array(
'before' => '<div class="home-welcome"><div class="wrap">',
'after' => '</div></div>',
)
);
}
// Display content for the "Home Gallery" section
function utility_pro_add_home_gallery() {
printf( '<div %s>', genesis_attr( 'home-gallery' ) );
genesis_structural_wrap( 'home-gallery' );
genesis_widget_area(
'utility-home-gallery-1',
array(
'before'=> '<div class="home-gallery-1 widget-area">',
'after' => '</div>',
)
);
genesis_widget_area(
'utility-home-gallery-2',
array(
'before'=> '<div class="home-gallery-2 widget-area">',
'after' => '</div>',
)
);
genesis_widget_area(
'utility-home-gallery-3',
array(
'before'=> '<div class="home-gallery-3 widget-area">',
'after' => '</div>',
)
);
genesis_widget_area(
'utility-home-gallery-4',
array(
'before'=> '<div class="home-gallery-4 widget-area">',
'after' => '</div>',
)
);
genesis_structural_wrap( 'home-gallery', 'close' );
echo '</div>'; // end .home-gallery
}
// Display content for the "Call to action" section
function utility_pro_add_call_to_action() {
genesis_widget_area(
'utility-call-to-action',
array(
'before' => '<div class="call-to-action-bar"><div class="wrap">',
'after' => '</div></div>',
)
);
}
// Display latest posts instead of static page
function utility_pro_front_loop() {
global $query_args;
genesis_custom_loop( wp_parse_args( $query_args, array( 'post_type' => 'post', 'paged' => get_query_var( 'page' ) ) ) );
}
genesis();