/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<ul class="feature-images"> <?php global $wpdb; $sql = "SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'lab-image' AND wposts.post_status = 'publish' AND wposts.post_type = 'post' ORDER BY wposts.post_date DESC LIMIT 3"; $pageposts = $wpdb->get_results($sql, OBJECT); $output = $pre_HTML; foreach ($pageposts as $post) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>" title="Link to <?php the_title(); ?>"> <img src="<?php echo get_post_meta($post->ID, "lab-image", $single = true); ?>" alt="<?php the_title(); ?>" /></a></li> <?php endforeach; ?> </ul>
Comments
