输出缩略图地址
程序员文章站
2022-04-10 14:46:19
...
//输出缩略图地址 function post_thumbnail_src() { global $post; if ($values = get_post_custom_values("thumb")) { //输出自定义域图片地址 $values = get_post_custom_values("thumb"); $post_thumbnail_src = $values [0]; } elseif (has_post_thumbnail()) { //如果有特色缩略图,则输出缩略图地址 $thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $post_thumbnail_src = $thumbnail_src [0]; } else { $post_thumbnail_src = ''; }; echo $post_thumbnail_src; }