WordPress从循环外部检索自定义字段
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WordPress从循环外部检索自定义字段相关的知识,希望对你有一定的参考价值。
<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); 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>
以上是关于WordPress从循环外部检索自定义字段的主要内容,如果未能解决你的问题,请参考以下文章