繁体   English   中英

get_posts仅显示指向主页的链接

[英]get_posts only displaying a link to homepage

我正在开发我的第一个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_posts切换为使用WP_query,并且遇到了同样的问题。 事实证明,问题实际上出在元值上,而不是查询本身。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM