WordPress query posts of certain custom field values

/ Published in: PHP
Save to your folder(s)

Copy this code and paste it in your HTML
  1. <?php $headerimage = get_posts('showposts=3&meta_key=headerimage'); foreach($headerimage as $post) : setup_postdata($post); ?>
  2. <div id="header-image"><a href="<?php the_permalink(); ?>" title="Latest experiment from the DesignLab"><img src="<?php echo get_post_meta($post->ID, "headerimage", true); ?>" alt="" border="0" /></a></div>
  3. <?php endforeach; ?>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.