wp get_post自定义帖子类型和图片

时间:2016-02-17 09:11:11

标签: wordpress

我正在尝试获得自定义帖子类型的10个帖子

$args = array( 'numberposts' => 10, 'post_type' => 'mycustomposttype'  );

    $myposts = get_posts( $args ); 


    foreach ( $myposts as $post ) : setup_postdata( $post );    

        if ( has_post_thumbnail() ) 
        {
            $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); 


            //my template here  
        }

    endforeach; 

if语句

if ( has_post_thumbnail() ) 

返回false但我的所有自定义帖子都有图片

现在,如果我更改'号码信息' => 10到' numberposts' => 100 我得到了帖子的图像

我在这里缺少什么

0 个答案:

没有答案
相关问题