Created
May 13, 2014 23:28
-
-
Save yratof/1dcfd9e69b18dd294d8b to your computer and use it in GitHub Desktop.
Get the posts' attachments
This file contains hidden or 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 $args = array( | |
'post_type' => 'attachment', | |
'numberposts' => 1, | |
'orderby' => 'rand', | |
'post_status' => null, | |
'post_parent' => get_the_ID(), | |
'post_mime_type' => 'image' | |
); | |
$images = get_children( $args ); | |
if ($images) { | |
foreach ( $images as $attachment_id => $attachment ) { ?> | |
<div class="relative"> | |
<?php echo wp_get_attachment_image( $attachment_id, 'large' ); ?> | |
<div class="overlay"> | |
<h2><?php echo apply_filters( 'the_title', $attachment->post_title ); // Image Title ?></h2> | |
<h3><?php echo get_the_title(); // Designer ?></h3> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment