/
loop.php
67 lines (48 loc) · 1.15 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
<?php if (is_home) : ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content(); ?>
</article>
<?php endwhile; ?>
<?php get_template_part('inc/component', 'pagination'); ?>
<?php else : ?>
<article>
<h2>No Posts Found</h2>
</article>
<?php endif;
// Else if is another page name
elseif (is_page('yourPageName')) :
// Arguments
$args = array();
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
// do something
}
} else {
// if no posts are available
}
// Reset original Post Data
wp_reset_postdata();
// Otherwise, do this...
else :
// Arguments
$args = array();
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
// if no posts are available
}
} else {
// if no posts are available
}
// Reset original Post Data
wp_reset_postdata();
endif; ?>