• Hi, I’m trying to create my archive page as just a page of thumbnails – if possible with pagination (all my entries are just images). Clicking on a thumbnail would go to full entry. Any idea how I might do this?

    I’m using Kubrick theme – archives.php

Viewing 4 replies - 1 through 4 (of 4 total)
  • You could use custom fields to do this. Everytime you create a post and you upload and dispay and image in the post you could also upload a thumbnail image of a set size and then add it as a custom field.

    Then in your archive.php template instead of calling the page content through <?php the_content(); ?> you could call the custom field instead. The code below may help with this.

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <img src="<?php echo get_post_meta($post->ID, "Archive-Image", true); ?>" alt="<?php the_title(); ?> Image" />
    
    <?php endwhile; ?>

    This will get the image from the custom field with the key “Archive Image” and display for each post. If you want to link that image to the post itself, then just wrap it is an a tag with a permalink like this:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "Archive-Image", true); ?>" alt="<?php the_title(); ?> Image" /></a>
    
    <?php endwhile; ?>

    Hope this helps.

    Thread Starter markoburns

    (@markoburns)

    Thanks. Will give it a go.

    Its quite messy getting thumbnails in those fields. Given that they would all end up in my uploads folder and they get tagged with their size at end of filename I suppose this should work? if I’m just posting in the image url in the field?

    in custom field: https://www.imageurl.com/imagename

    <img src="<?php echo get_post_meta($post->ID, "Archive-Image", true); ?>-150x150.jpg" alt="<?php the_title(); ?> Image" />
    Thread Starter markoburns

    (@markoburns)

    Hi – tried that but it just seems to give me a blank page:
    (my custom field=thumbs)

    <?php
    /*
    Template Name: Archives
    */
    ?>
    
    <div id="content" class="narrowcolumn">
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <img src="<?php echo get_post_meta($post->ID, "thumbs", true); ?>" alt="<?php the_title(); ?> Image" />
    
    <?php endwhile; ?>
    
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
    Thread Starter markoburns

    (@markoburns)

    hi – code seems to work if I put it in my main index.php file but not in my archive.php template file – strange.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘display thumbnails of entries in archive?’ is closed to new replies.