Forums

Using Post thumbnails questions (3 posts)

  1. Mercer2789
    Member
    Posted 2 years ago #

    I tried posting this question earlier but I formatted it wrong so I'll try again. I have a template attached to some of my pages that displays a list of posts. I'm trying to change two of the loops to display post thumbnails in place of the title.

    For the section that lists the most recent posts the current script is:

    <?php get_archives('postbypost', 9); ?>

    I'm not sure what to put in place of "postbypost" and probably cant use "get archives" since it most likely lists only the titles as permalinks to the actual posts. I just need to pull up a specific number of the most recent posts and display them as post thumbnails that are links to the actual posts.

    The script that displays the random posts goes like this:

    <?php
    $rand_posts = get_posts('numberposts=9&orderby=rand');
    foreach( $rand_posts as $post ) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

    So I tried using a few codex I found to display the post thumbnails in place of the title but none of them worked.

    I thought generally just using :
    <?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
    Would display the thumbnails if I replaced:
    <?php the_title(); ?>
    with the thumbnail code.

    I tried a few different variations and none display the post thumbnail.

    I'm having trouble finding documentation for displaying post thumbnails in the theme as well as in applications like this one. hopefully someone could show me a link to any explanations/guides or a quick fix for these two specific problems. It would be very much appreciated.

    As reference I found this code to generate thumbnails in the loop.
    I'm just not sure how to implement this into those types of loops.

    <?php
    if ( has_post_thumbnail() ) {
    	// the current post has a thumbnail
    } else {
    	// the current post lacks a thumbnail
    }
    ?>
  2. Mercer2789
    Member
    Posted 2 years ago #

    If there is any way I can explain this better or something I left out let me know. It may not even be possible for all I know. I really need help here so any feed back would be highly appreciated.

  3. Mercer2789
    Member
    Posted 2 years ago #

    Please help meeeeee.... hahaha

Topic Closed

This topic has been closed to new replies.

About this Topic