Skip to content

Instantly share code, notes, and snippets.

@miklb
Created March 26, 2012 15:12
Show Gist options
  • Save miklb/2205762 to your computer and use it in GitHub Desktop.
Save miklb/2205762 to your computer and use it in GitHub Desktop.
loop through images
remove_action( 'genesis_post_content' , 'genesis_do_post_content' );
add_action( 'genesis_post_content' , 'kkf_do_custom_post_content' );
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
function kkf_do_custom_post_content() { ?>
<?php $photos = kkf_get_images('posts_per_page=12', true); ?>
<?php if ( $photos ) { ?>
<ul class="newsletter-gallery">
<?php foreach ($photos as $photo) {
$url = wp_get_attachment_url($photo->ID);
$link = substr($url,0,-5);
?>
<li>
<a href="<?php echo $url; ?>" title="<?php echo apply_filters( 'the_title', $attachment->post_title ); ?>"><img src="<?php echo wp_get_attachment_thumb_url($photo->ID); ?>"></a>
<p><a href="<?php echo $link; ?>" title="">Download</a></p>
</li>
<?php } }
?>
</ul> <?php
}
genesis();
@miklb
Copy link
Author

miklb commented Mar 26, 2012

related function for kkf_get_images

function kkf_get_images() { return get_posts(wp_parse_args($overrides, array( 'posts_per_page' => 12, 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ))); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment