Wordpress custom code to display latest image

Discussion in 'PHP' started by incoe, Apr 30, 2012.

  1. #1
    am currently query_posts to grab the latest posts thumbs and displaying them on the home page as such

    
    <ul class="theteam">
    <?php query_posts( 'posts_per_page=4&cat=-12'); ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <?php   /*get the thumb image*/
        $imgs = get_the_post_thumbnail($id,'medium');
    
        /*get the img URL, delete the <img /> tag */    
    
        $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $imgs, $matches);
    
        /*the image URL*/
    
        $img = $matches [1] [0];
    ?>
    
    <li class="figure">
        <a href="<?php the_permalink(); ?>"><img src="<?php echo  $img; ?>" alt="Post image" />
        <div class="figcaption"><span class="cap-left"><?php the_title(); ?></span></div></a>
    </li>
    <?php endwhile; ?>
    
    PHP:
    am also grabbing the title and displaying it with a hover effect over the image when mouse over using css, my question is can i display the image post from 4 different categories? like to display only the last post from these categories.

    in image 1 it will always grab from category 1, image 2 from category 4, image 3 from category 2 etc ... or will i have to keep repeating this loop to get he results i need?

    Thanks in advance.
     
    incoe, Apr 30, 2012 IP