I have the following query
<?php // gets attached images
$counter = 3;
$args = array(
'post_type' => 'attachment',
'numberposts' => -1, // posts_per_page doesn't work for get_posts!
'orderby' => 'rand',
'caller_get_posts' => 1,
'post_mime_type' => 'image',
'post_status' => null,
'post_parent' => null, // any parent
);
$attachments = get_posts($args);
if ($attachments) {
echo '<ul>';
// count number of available images and change if less than the specified limit
if ( count($attachments) < $counter )
$counter = count($attachments);
foreach ($attachments as $post) {
if ( $counter > 0 ) {
setup_postdata($post);
$image = wp_get_attachment_image_src( $post->ID, 'thumbnail', false );
echo '<li class="media"><a href="'.get_permalink().'" title="'.get_the_title().'" style="background-image: url('.$image[0].');">'.get_the_title().'</a></li>';
$counter--;
}
}
echo '</ul>';
}
?>
What I am unable to figure out on how to add a custom_post_type that i have created to it.
Thanks