-
Notifications
You must be signed in to change notification settings - Fork 0
/
attachment.php
94 lines (78 loc) · 3.34 KB
/
attachment.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
<?php get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<!-- post -->
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<?php if( is_single() ) { ?>
<h1 class="post-title"><?php the_title(); ?></h1>
<?php } else { ?>
<h1 class="post-title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<?php } ?>
<div class="post-text">
<?php
if ( ! empty( $post->post_parent ) ) { ?>
<p class="page-title">
<?php _e('This is an attachment for the post','comet'); ?> <a href="<?php echo get_permalink( $post->post_parent ); ?>" rel="gallery"><?php echo get_the_title( $post->post_parent ); ?></a>
</p>
<?php
}
if ( wp_attachment_is_image() ) {
$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
foreach ( $attachments as $k => $attachment ) {
if ( $attachment->ID == $post->ID )
break;
}
$k++;
// If there is more than 1 image attachment in a gallery
if ( count( $attachments ) > 1 ) {
if ( isset( $attachments[ $k ] ) )
// get the URL of the next image attachment
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
else
// or get the URL of the first image attachment
$next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
} else {
// or, if there's only 1 image attachment, get the URL of the image
$next_attachment_url = wp_get_attachment_url();
}
?>
<p class="attachment">
<?php echo wp_get_attachment_image( $post->ID, array( 900, 9999 ) ); ?>
</p>
<p><?php if ( !empty( $post->post_excerpt ) ) the_excerpt(); ?></p>
<div class="post">
<div class="alignleft"><?php previous_image_link( false, '← Previous Image' ); ?></div>
<div class="alignright"><?php next_image_link( false, 'Next Image →' ); ?></div>
</div>
<?php } else { ?>
<a href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php echo basename( get_permalink() ); ?></a>
<?php } ?>
</div>
<div class="post-meta">
<div class="row">
<?php if ( comments_open() ) { ?>
<div class="alignright"><?php comments_popup_link(__('No Comments','comet'),__('1 Comment','comet'),__('% Comments','comet')); ?></div>
<?php } ?>
<span class="post-author">by <?php the_author_posts_link() ?> on </span><em><?php the_time('F j, Y') ?></em>
• <a href="<?php the_permalink() ?>" rel="bookmark">Permalink</a>
<?php edit_post_link(__('Edit Post','comet'), ' • ', ''); ?>
</div>
</div>
</div>
<!--/post -->
<div class="sep"></div>
<?php comments_template(); ?>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« '.__('Older Posts','comet')) ?></div>
<div class="alignright"><?php previous_posts_link(__('Newer Posts','comet').' »') ?></div>
</div>
<?php else : ?>
<div class="post">
<h1 class="post-title"><?php _e('Post not found','comet'); ?></h1>
<div class="post-text">
<p><?php _e('The post you were looking for could not be found.','comet'); ?></p>
</div>
</div>
<?php endif; ?>
<?php get_footer(); ?>