Hey all,

I've got masonry working on my site


But for the life of me, I cannot work out how the images are handled.

Is there a method where it grabs the post featured image??

This is the code i'm using for my index.php and categories.php pages

<div id="container">
        <div id="content">
    <?php query_posts('posts_per_page=15'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <a href="<?php the_permalink(); ?>" class="box col<?php echo rand(2,4); ?>">
            <span class="title"><?php the_title(); ?></span>
            <img src="<?php echo get_post_meta($post->ID, 'PostThumb', true); ?>" alt="" />
            <span class="ex"><?php the_excerpt(); ?></span>
    <?php endwhile; endif; ?>

The code is from this tutorial http://digwp.com/2010/08/randomized-grid-of-posts/#comment-11756

I know this needs to change

<img src="<?php echo get_post_meta($post->ID, 'PostThumb', true); ?>" alt="" />

Or it might be that my input method for images is not right.

This is an example of what i'm aiming for http://thoughtandtheory.com/collection/

I'm still unclear about how images are handled?

Anyone shed some light on this??

1 answer

This was chosen as the best answer

Code sense for this text editor isn't letting me share what I need to share so find the snippet here:


Basically, you'll want to consider using the WordPress post thumbnail function which supports specifying a unique thumbnail to associate with each post. Provide a fallback image though in case a thumbnail is not set.

Answered over 7 years ago by Derek Punsalan