Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a category in my blog called "work", and I will be assigning each post a thumbnail.

This category will be excluded from my blog's navigation, but added as a fake page on my page nav bar.

Basically, I want to create a 3 x 3 grid listing of thumbnails which link to that piece of work, how would I go about doing this? I don't even know where to begin with this?!

Thanks in advance!

share|improve this question
    
Am I correct when I think you want a category overview page /category/work/ with this special layout, next to your regular category overview like /category/banana/ that still displays them in a regular layout? –  Jan Fabry Nov 17 '10 at 11:46
    
Almost. I would like a normal page layout, but in the footer of every page or post I'd like to call the latest posts in the "work" category, but only show the post-thumbnail and link to that post. Is this possible? –  tjcss Nov 29 '10 at 11:30
add comment

1 Answer

You probably want to define a size for post thumbnails for this side-bar area first. This needs to be registered with your theme so you can refer to it later one.

Then you can make use of the get_the_post_thumbnail() function passing the ID of the post as well as your post thumbnail size name as the second argument.

Now the last thing you need to know is to get all posts of the category you like to get the thumbnails from. This can be done with a new wp_query just getting all categories posts.

Then you combine this all together.

Example Code

This is some example code to display the thumbnails registered with the sidebar-thumbnail size. You need to do this generally with your theme, probably in the themes function.php. Please see codex how to do that. This little code takes care to query all thumbnails by category and then inserts a <br> tag after every third thumbnail:

$myThumbnailSize = 'sidebar-thumbnail';
$myCategoryID = 12;
$myThumbnailsPerRow = 3;
query_posts('category='.$myCategoryID);
if (have_posts()) { 
    $count = 0;
    while (have_posts()) { 
        the_post();
        echo get_the_post_thumbnail($post->ID, $myThumbnailSize);
        if (0 === ++$count % $myThumbnailsPerRow) echo '<br>';
    }
}
wp_reset_query();

It's sample code so untested, but it probably helps you to get things running. All the functions used in there are documented in worpdress codex btw, so you can learn more about them there.

share|improve this answer
    
I've figured out how to add a post-humbnail / featured image, and this seems to work fine. what I would like to do is have a bit of code that sits in my footer.php that queries the last 9 posts from category x and shows the thumbnail and the url ONLY for each of those posts. Hope this makes sense? –  tjcss Nov 29 '10 at 11:45
    
This works basically the same, add the needed parameters for this to wp_query() and then get additionally the URL of $post via get_permalink($post->ID); - You find the parameters in codex. –  hakre Nov 30 '10 at 11:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.