Php 获取仅显示主页链接的帖子

Php 获取仅显示主页链接的帖子,php,wordpress,loops,Php,Wordpress,Loops,我正在开发我的第一个Wordpress主题,我的第一个循环只输出一个项目:一个指向主页的链接(不是我试图在数组中传递的任何参数) 以下是php和html: <div class="services_list"> <?php $args = array( 'posts_per_page'=> 999, 'orderby' => 'menu_order',

我正在开发我的第一个Wordpress主题,我的第一个循环只输出一个项目:一个指向主页的链接(不是我试图在数组中传递的任何参数)

以下是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 -->


如果这个问题已经得到回答,我很抱歉,但我似乎找不到任何答案。

有效!谢谢。我从get_帖子切换到使用WP_查询,遇到了同样的问题。事实证明,问题实际上与元值有关,而不是查询本身。

对于二次循环,您应该使用。有关何时使用的说明,请参阅。