有三个人已经试图解决这个问题,我们的结果是零。我只想显示meta\\u键“featured\\u image”中有值的帖子。
所以如果“featured\\u image”不为空,则显示帖子。代码如下:
<ul>
<?php
$args = array(
\'showposts\' => 5,
\'meta_query\' => array(
array(
\'key\' => \'featured_image\',
\'value\' => \'\',
\'compare\' => \'!=\'
)
)
);
$ft_pagination = new WP_Query( $args );
?>
<?php while ($ft_pagination->have_posts()) : $ft_pagination->the_post(); ?>
<?php $ftimage = get_post_meta(get_the_id(), \'featured_image\', TRUE); ?>
<li>
<article>
<a href="">
<?php if ($ftimage): ?>
<img src="<?php bloginfo(\'template_directory\'); ?>/timthumb.php?src=<?php echo $ftimage; ?>&w=84&h=60" alt="" />
<?php else: ?>
<img src="<?php bloginfo(\'template_directory\'); ?>/timthumb.php?src=/wp-content/themes/ssv/images/review-default.gif&w=84&h=60" alt="" />
<?php endif; ?>
</a>
</article>
</li>
<?php
endwhile;
wp_reset_query();
?>
</ul>
我们已经尝试了所有我们能想到的组合,不推荐的meta\\u*选项、query\\u posts、get\\u posts,而不是WP\\u query。。。没有什么打印了select语句,未显示任何元值字段。它存在-对于post(每个post),它存在于db中。我们现在已经看到了每个关于这个主题的帖子,包括:
query_posts and only show results if a custom field is not empty
废话。请帮助。。。