我正在开发我的第一个Wordpress主题,而我的第一个循环只输出1个项目:指向主页的链接(不是我试图在数组中传递的任何参数)。
这是php和html:
<div class="services_list">
<?php
$args = array(
'posts_per_page'=> 999,
'orderby' => 'menu_order',
'order' => 'ASC',
'post_type' => 'service',
'meta_key' => 'featured',
'meta_value' => '1'
);
// The Query
get_posts( $args );
// The Loop
while ( have_posts() ) : the_post(); ?>
<div class="service_item">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="service_top_link">
<div class="service_image"><?php the_post_thumbnail( array(120,120) ); ?></div>
</a>
<h3 class="service_title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
<div class="service_excerpt"><?php the_excerpt(); ?></div>
<a href="<?php the_permalink(); ?>" title="Learn More" class="learn_more" role="button">Learn More</a>
</div><!-- .service_item -->
<?php endwhile;
// Reset Query
wp_reset_query();
?>
</div><!-- .services_list -->
如果这个问题已经得到解答,我很抱歉,但我似乎无法找到任何问题。
答案 0 :(得分:0)
工作!谢谢。我从get_posts切换到使用WP_query并遇到了同样的问题。事实证明问题实际上是元值,而不是查询本身。