Thursday, June 16, 2011

Display all images in your site

Copy this code to functions.php

<?php
function latest_images() {   
    $images = get_children( 'post_type=attachment&post_mime_type=image&numberposts=3&order=DESC&post_parent=' );
    echo "<ul>";
    foreach($images as $image) {
        echo "<li><a href='" . get_permalink($image->ID) . "'><img src='" . $image->guid . "' width='252' height='135' /></a></li>";   
    }
    echo "</ul>";
}

?>
 
and place this to your index.php

<?php latest_images(); ?>

No comments:

Post a Comment