WordPress.org

Forums

Thumbnails in archives page (13 posts)

  1. tyh
    Member
    Posted 10 years ago #

    Hi,

    I'm using wordpress for my photoblog, and I'd like to have an archives page with thumbnails of photos shown. Thumbnails are put under excerpt. I've modified archives.php and put in the code below:

    <?php while (have_posts()) : the_post(); ?>
    <?php the_excerpt(); ?>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>

    Loading the archives page I get the error

    Parse error: parse error, unexpected T_ELSE in /archives.php on line 15

    with line 15 being <?php endwhile; else: ?>

    What am I doing wrong? How do I get thumbnails to show as archives?

  2. Return your Archives Template (archives.php) to its original state and replace:

    <?php the_excerpt(); ?>

    with:

    <?php the_content(); ?>

  3. Kafkaesqui

    Posted 10 years ago #

    You have no if statement starting off your loop, hence the 'else' error. Change the first line to:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

  4. tyh
    Member
    Posted 10 years ago #

    The page loads ok, but thumbnails are not showing
    http://ayutheos.uni.cc/blog_wp/index.php?pagename=archives-index

  5. Kafkaesqui

    Posted 10 years ago #

    I skipped over your first post and missed what you were trying to do.

    The reason nothing is showing is that the loop you're using is (or that is, should be) displaying the excerpt from the Page itself. It knows nothing about the posts archive.

    Doing this through a Page alone can be a bit complicated, but if you set up an archive template as well (archive.php) to display excerpts, you can work them in tandem by changing your Page template's loop (but leaving the one in archive.php as normal) to something like this:

    <?php $posts = new WP_Query("showposts=10");
    while($posts->have_posts()) : $posts->the_post(); ?>
    <?php the_excerpt(); ?>
    <?php endwhile; ?>

    This sets up a new post query to display in the Page. The WP_Query argument 'showposts' defines how many to display in your custom loop, which you can set to as many as you want to be shown on the Page.

  6. I skipped over your first post and missed what you were trying to do.

    Me too, sorry.

  7. thitipatn
    Member
    Posted 10 years ago #

    Yes, you need to create an Archive.php as a separate page instead of trying to integrate everything into the index.php. I did that on my photoblog.

  8. tyh
    Member
    Posted 10 years ago #

    Thanks! Thumbnails are showing now :)
    But when I click archives for certain month/category I get to the individual posts. How do I get the links to update the archives page with corresponding month/category thumbnails showing?

  9. Kafkaesqui

    Posted 10 years ago #

    Actually, you're viewing the monthly archive, not individual posts, though it looks like you figured that out since the monthly archive pages look to be showing full months now. As I mention above, place an archive.php in your theme's directory; easiest way to do this is to copy index.php. Then make the change to The Loop in archive.php to only display an excerpt (i.e. the_excerpt();).

  10. tyh
    Member
    Posted 10 years ago #

    Ahh...thanks!

  11. OrchidRed
    Member
    Posted 9 years ago #

    I just used this thread to make my archives into thumbnail galleries (yay!) but for some reason they are displaying as one long column instead of across the content area (boo!). I don't have any extra or <br> anywhere, nor any <div> tags so I have no idea why this is happening. Help, please? Aaa!

  12. OrchidRed
    Member
    Posted 9 years ago #

    I looked in the source file that my archives are generating when I load the page and it look like WP is automatically inserting and <br> tags. Any idea how to stop it from doing this?

  13. tyh
    Member
    Posted 9 years ago #

    OrchidRed,
    I use css to make the image thumbnails to go across. I have my thumbnails images set to float left, inside a container of a certain width. Hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Topic