forked from billerickson/EA-Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloop.php
68 lines (51 loc) · 1.24 KB
/
loop.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
<?php
/**
* Loop
*
* @package EAStarter
* @author Bill Erickson
* @since 1.0.0
* @license GPL-2.0+
**/
/**
* Default Loop
*
*/
function ea_default_loop() {
if ( have_posts() ) :
tha_content_while_before();
/* Start the Loop */
while ( have_posts() ) : the_post();
tha_entry_before();
$partial = apply_filters( 'ea_loop_partial', is_singular() ? 'content' : 'archive' );
$context = apply_filters( 'ea_loop_partial_context', is_search() ? 'search' : get_post_type() );
get_template_part( 'partials/' . $partial, $context );
tha_entry_after();
endwhile;
tha_content_while_after();
else :
tha_entry_before();
$context = apply_filters( 'ea_empty_loop_partial_context', 'none' );
get_template_part( 'partials/archive', $context );
tha_entry_after();
endif;
}
add_action( 'tha_content_loop', 'ea_default_loop' );
/**
* Entry Title
*
*/
function ea_entry_title() {
echo '<h1 class="entry-title">' . get_the_title() . '</h1>';
}
add_action( 'tha_entry_top', 'ea_entry_title' );
/**
* Post Comments
*
*/
function ea_comments() {
if ( is_single() && ( comments_open() || get_comments_number() ) ) {
comments_template();
}
}
add_action( 'tha_content_while_after', 'ea_comments' );