Forums

[resolved] Post listing within a post (4 posts)

  1. antirem
    Member
    Posted 2 years ago #

    On the right hand side of my blog I want an image listing of each and every post (I've added the images etc..)

    The below code works great, IF it is on the homepage.

    <?php if (have_posts()) : ?>
      <?php while (have_posts()) : the_post(); ?>
        <?php if(get_post_meta($post->ID, "small-image", true)) : ?>
          <a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "small-image", true); ?>" /></a>
        <?php endif; ?>
      <?php endwhile; ?>
    <?php endif; ?>

    When this code is on any specific blog post it will only find the image for the current post.

    What is the post call that I need to use for it to act like it is starting at the root of my site?

    Thanks!

  2. Edward Caissie
    Member
    Posted 2 years ago #

  3. antirem
    Member
    Posted 2 years ago #

    With enough tweaking I got it to work. I haven't a clue what most of it means.. but eventually it turned out the way I wanted.

    Thanks!

    <?php if (query_posts('posts_per_page=20')) : ?>
      <?php while (have_posts()) : the_post(); ?>
        <?php if(get_post_meta($post->ID, "small-image", true)) : ?>
          <a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "small-image", true); ?>" /></a>
        <?php endif; ?>
      <?php endwhile; ?>
      <?php wp_reset_query(); ?>
    <?php endif; ?>
  4. Edward Caissie
    Member
    Posted 2 years ago #

    Good for you!

Topic Closed

This topic has been closed to new replies.

About this Topic