0

I'm getting "an undefined variable in line 6" while trying to display an image from a custom field. It's pulling the name/link of file; but not image. Here is my code

<?php query_posts( 'cat=36&post_type=athletes&showposts=1&orderby=rand'); ?>
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
  <a href="<?php the_permalink() ?>">Read More</a>

 <?php $imageid = get_post_meta($post->ID, 'athletethumbnail', true); ?>
 <img src="<?php echo wp_get_attachment_url( $imageid ); ?>" height="192" width="192" />
          <?php the_title(); ?>

  </article>

  <?php endwhile; ?>
  <?php else : ?>
  <?php endif; ?>
0

Try this:

<?php $imageid = get_post_meta(get_the_ID(), 'athletethumbnail', true); ?>

Also, you might want to read this.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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