Posted By

davebowker on 11/09/08


Tagged

wordpress query field optional custom advanced


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

nerdfiles
SmpleJohn


WordPress query posts of certain custom field values


 / Published in: PHP
 

  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  

Comments

RSS Icon Subscribe to comments
Posted By: SmpleJohn on November 10, 2008

Haven't tried it, but looks good. Could be useful for Wordpress as a CMS.

You need to login to post a comment.