Search
Close this search box.

wordpress根据ID拿特色图片代码

function add_votes_list_options(){
    if( isset($_POST['action']) && ($_POST['action'] == 'vote_post_lists') ){ 
        $termid = (int)$_POST['postid'];
        if($termid == 999999999){
            $termid = '';
        }
        $arris  = array(
           'post_type'  => 'post',
           'posts_per_page' => 9,
           'category'  => $termid
       
        );
        $results = get_posts( $arris );
        foreach ($results as $val){
            $thumbnail_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($val->ID), 'thumbnail');
            $val->thumbnail = $thumbnail_image_url[0];
        }
        $queryww = json_encode($results);
        echo $queryww;
        die;
    }
}

发表评论

Optimized by WPJAM Basic