/
loop.php
159 lines (115 loc) · 5.45 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
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
<?php
get_template_part('loop-header'); // loop-header.php contains anything to be displayed before the list of posts
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div <?php post_class(); ?>>
<div class="post-title">
<!-- Post Header Begin -->
<?php get_template_part('post-header'); // post-header.php contains the Post TItle and other post meta information ?>
<!-- Post Header End -->
</div>
<div class="post-entry">
<!-- Post Entry Begin -->
<?php get_template_part('post-entry'); // post-entry.php contains the post content ?>
<!-- Post Entry End -->
</div>
<div class="post-footer">
<!-- Post footer Begin -->
<?php get_template_part('post-footer'); // post-footer.php contains post timestamp and copyright information ?>
<!-- Post Footer End -->
</div>
</div>
<!-- Comments Begin -->
<?php if ( is_single() || ( is_page() && comments_open() ) ) { // only display the comments on a single blog post or on a Page with open comments
comments_template(); /* comments template */
} ?>
<!-- Comments End -->
<?php endwhile;
get_template_part('loop-footer'); // loop-footer.php contains anything to be displayed after the list of posts
else : ?>
<h2 class="center">Not Found</h2>
<p class="center">
<?php _e("Sorry, but you are looking for something that isn't here."); ?>
</p>
<?php endif;
/*
Reference:
=============================================================================
The following functions, tags, and hooks are used (or referenced) in this Theme template file:
***********************
comments_open()
----------------------------------
comments_open() is a WordPress template conditional tag.
Codex reference: http://codex.wordpress.org/Function_Reference/comments_open
comments_open() is a boolean (returns TRUE or FALSE) conditional tag that returns true if
comments are open for the current post.
comments_open( $postid ) accepts one argument:
- $postid: PostID of the post being checked. Defaults to the current post.
comments_open() must be used from within the Loop, unless the $postid parameter is used.
***********************
get_template_part()
----------------------------------
get_template_part() is a WordPress template tag.
Codex reference: http://codex.wordpress.org/Function_Reference/get_template_part
get_template_part() is used to include a Theme template file within another. This function facilitates
re-use of Theme template files, and also facilitates child Theme template files to take precedence
over parent Theme template files.
get_template_part( $file ) will attempt to include file.php. The function will attempt to
include files in the following order, until it finds one that exists:
- the Theme's file.php
- the parent theme's file.php
get_template_part( $file , $foo ) will attempt to include file-foo.php. The function will
attempt to include files in the following order, until it finds one that exists:
- the Theme's file-foo.php
- the Theme's file.php
- the parent theme's file-foo.php
- the parent theme-s file.php
***********************
have_posts()
----------------------------------
have_posts() is a WordPress template conditional tag.
Codex reference: http://codex.wordpress.org/User:Samsm/have_posts
have_posts() is a boolean (returns TRUE or FALSE) conditional tag that returns true if
the current query has posts available. It is primarily used in conjunction with the_post()
as part of the call to the Loop.
Example (the Loop):
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
***********************
is_page()
----------------------------------
is_page() is a WordPress template conditional tag.
Codex reference: http://codex.wordpress.org/Function_Reference/is_page
is_page() is a boolean (returns TRUE or FALSE) conditional tag that returns true if
a page ("page" post-type) is currently displayed.
A page corresponds to the page.php Theme template file in the
Theme hierarchy, and if the body_class() hook is used, the <body> tag of an
page will have class="page".
***********************
is_single()
----------------------------------
is_single() is a WordPress template conditional tag.
Codex reference: http://codex.wordpress.org/Function_Reference/is_single
is_single() is a boolean (returns TRUE or FALSE) conditional tag that returns true if
a single post ("post" post-type, i.e. a single blog post) is currently displayed.
A single post corresponds to the single.php Theme template file in the
Theme hierarchy, and if the body_class() hook is used, the <body> tag of a
single post will have class="single".
***********************
post_class()
----------------------------------
post_class() is a WordPress template tag.
Codex reference: http://codex.wordpress.org/Template_Tags/post_class
post_class() is added inside the HTML <div> or <span> tag that contains the post,
and outputs various CSS class declarations, depending on which post is currently
being displayed.
For the full list of CSS classes returned by post_class(), see the Codex.
***********************
the_post()
----------------------------------
the_post() is a WordPress template tag.
Codex reference: http://codex.wordpress.org/User:Jefte/the_post
the_post() is used to output the content of each post. It is primarily used in conjunction
with have_posts() as part of the call to the Loop.
Example (the Loop):
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
=============================================================================
*/ ?>