Php 滑块中的过滤柱
在MySlider(s3Slider JQuery)调用并显示最后5篇文章的那一分钟。它从标记为“thumb”的自定义字段中获取图像 我希望滑块只调用在“thumb”自定义字段中有值的图像。这可能吗 当前查询是Php 滑块中的过滤柱,php,javascript,jquery,wordpress,slider,Php,Javascript,Jquery,Wordpress,Slider,在MySlider(s3Slider JQuery)调用并显示最后5篇文章的那一分钟。它从标记为“thumb”的自定义字段中获取图像 我希望滑块只调用在“thumb”自定义字段中有值的图像。这可能吗 当前查询是 <?php $my_query = new WP_Query('showposts=5'); while ($my_query->have_posts()) : $my_query->the_post(); ?> <li class="sliderImage
<?php
$my_query = new WP_Query('showposts=5');
while ($my_query->have_posts()) : $my_query->the_post();
?>
<li class="sliderImage"> <a href="<?php the_permalink() ?>" rel="bookmark"> <img class="featimg" src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>" alt="<?php the_title(); ?>" />
<span class="des"><h1><?php the_title(); ?></h1><?php the_excerpt(); ?></span>
</a>
</li>
<?php endwhile; ?>
提前感谢。您需要将WP\u查询更改为以下内容(请注意,这仅适用于WP>=3.1): 当然,如果有人输入的值不是图像的有效路径(例如“blahblah”),它仍将被传递到
元素中的,因此在处理WordPress后端的输入时,您可能需要做一些进一步的检查/错误处理
$my_query = new WP_Query(
array(
'posts_per_page' => '5',
'meta_query' => array(
array(
'key' => 'thumb',
'value' => '',
'compare' => '!='
)
)
)
);