-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloop.php
127 lines (96 loc) · 4.97 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
<?php
/**
* The loop that displays posts.
*
* This can be overridden in child themes with loop.php or
* loop-template.php, where 'template' is the loop context
* requested by a template. For example, loop-index.php would
* be used if it exists and we ask for the loop with:
* <code>get_template_part( 'loop', 'index' );</code>
*/
?>
<!--If there are no posts to display, do this -->
<?php if ( ! have_posts() ) : ?>
<h1><?php _e( 'Not Found', THEME_NAME ); ?></h1>
<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', THEME_NAME ); ?></p>
<?php get_search_form(); ?>
<?php endif; ?>
<!--
============================================================
Start the Loop
============================================================
-->
<?php while ( have_posts() ) : the_post(); ?>
<!--
============================================================
How to display posts in the Gallery category.
The gallery category is the old way
============================================================
-->
<?php if ( ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) || in_category( _x( 'gallery', 'gallery category slug', THEME_NAME ) ) ) : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', THEME_NAME ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div> <!-- start entry content -->
<?php
$images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
?>
<?php if ( $images ) : ?>
<?php
$total_images = count( $images );
$image = array_shift( $images );
$image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
?>
<div class="gallery-thumb">
<a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
</div><!-- .gallery-thumb -->
<?php endif; ?>
<?php the_excerpt(); ?>
</div> <!-- end entry content -->
<div> <!-- start utility-->
<?php if ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) : ?>
<a href="<?php echo get_post_format_link( 'gallery' ); ?>" title="<?php esc_attr_e( 'View Galleries', THEME_NAME ); ?>"><?php _e( 'More Galleries', THEME_NAME ); ?></a>
<span class="meta-sep">|</span>
<?php elseif ( in_category( _x( 'gallery', 'gallery category slug', THEME_NAME ) ) ) : ?>
<a href="<?php echo get_term_link( _x( 'gallery', 'gallery category slug', THEME_NAME ), 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', THEME_NAME ); ?>"><?php _e( 'More Galleries', THEME_NAME ); ?></a>
<span class="meta-sep">|</span>
<?php endif; ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', THEME_NAME ), __( '1 Comment', THEME_NAME ), __( '% Comments', THEME_NAME ) ); ?></span>
<?php edit_post_link( __( 'Edit', THEME_NAME ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
</div><!-- end utility-->
</div><!-- #post-## -->
<?php else : ?>
<!--
============================================================
How to display all other posts
============================================================
-->
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', THEME_NAME ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<div> <!-- start utility-->
<?php if ( count( get_the_category() ) ) : ?>
<span class="cat-links">
<?php __( 'Posted in', THEME_NAME ); ?>
<?php get_the_category_list( ', ' ); ?>
</span>
<span class="meta-sep">|</span>
<?php endif; ?>
<?php $tags_list = get_the_tag_list( '', ', ' ); ?>
<?php if ( $tags_list ): ?>
<span class="tag-links">
<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', THEME_NAME ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
</span>
<span class="meta-sep">|</span>
<?php endif; ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', THEME_NAME ), __( '1 Comment', THEME_NAME ), __( '% Comments', THEME_NAME ) ); ?></span>
<?php edit_post_link( __( 'Edit', THEME_NAME ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
</div><!-- end utility -->
</div><!-- #post-## -->
<?php comments_template( '', true ); ?>
<?php endif; ?>
<?php endwhile; ?>
<!-- Display navigation to next/previous pages when applicable -->
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<?php next_posts_link( __( '← Older posts', THEME_NAME ) ); ?>
<?php previous_posts_link( __( 'Newer posts →', THEME_NAME ) ); ?>
<?php endif; ?>