第一张图片为特色图片

add_filter('get_post_metadata', function($value, $object_id, $meta_key, $single) {
if ($meta_key !== '_thumbnail_id' || $value) {
return $value;
}

preg_match('~<img[^>]+wp-image-(\\d+)~', get_post_field('post_content', $object_id), $matches);
if ($matches) {
return $matches[1];
}
return $value;
}, 10, 4);

functions.php

我们将在15分钟内联系你

免费提供行业网站方案以及海外推广计划