Skip to content

Instantly share code, notes, and snippets.

@cristovaov
Created January 29, 2014 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristovaov/8691070 to your computer and use it in GitHub Desktop.
Save cristovaov/8691070 to your computer and use it in GitHub Desktop.
loop-attachment.php
<?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">&larr;</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>&lt;&lt;Prev </span> <span id=next> Next&gt;&gt;</span>';
echo '</div>';
wp_reset_postdata();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment