Created
January 29, 2014 16:00
-
-
Save cristovaov/8691070 to your computer and use it in GitHub Desktop.
loop-attachment.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The loop that displays an attachment | |
* | |
*/ | |
?> | |
<?php if ( ! empty( $post->post_parent ) ) : ?> | |
<p class="page-title"><a href="<?php echo get_permalink( $post->post_parent ); ?>" title="<?php echo esc_attr( sprintf( __( 'Return to %s', 'twentyten' ), strip_tags( get_the_title( $post->post_parent ) ) ) ); ?>" rel="gallery"><?php | |
/* translators: %s - title of parent post */ | |
printf( __( '<span class="meta-nav">←</span> %s', 'twentyten' ), get_the_title( $post->post_parent ) ); | |
?></a></p> | |
<?php endif; ?> | |
<?php | |
$args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'inherit', 'post_parent' => $post->post_parent, 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ); | |
$attachments = get_posts( $args ); | |
if ( $attachments ) { | |
echo '<div class="cycle-slideshow" | |
data-cycle-fx="scrollHorz" | |
data-cycle-timeout="0" | |
data-cycle-prev="#prev" | |
data-cycle-next="#next" | |
data-cycle-slides="> div" | |
>'; | |
foreach ( $attachments as $post ) { | |
echo '<div>'; | |
echo wp_get_attachment_image($post->ID, 'large'); | |
echo '<div class="cycletwo-dscrptn">'; | |
echo '<p class="cycletwo-title">' . $post->post_title . '</p>'; | |
echo '<p class="cycletwo-cptn">' . $post->post_excerpt . '</p>'; | |
echo '</div>'; | |
echo '</div>'; | |
} | |
echo '</div>'; | |
echo '<div class="cycletwo-nav">'; | |
echo '<span id=prev><<Prev </span> <span id=next> Next>></span>'; | |
echo '</div>'; | |
wp_reset_postdata(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment