WordPress 获取特色图像地址主要需要用到两个函数 get_post_thumbnail_id 和 wp_get_attachment_image_src。下面是分别获取f 6 7小、中、M X o ^ ` 7 R大、完整、指定图片规格的图片地址的方法
获取特色图像:小
- <?php
- $thumbnail_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail');
- echo $thumbnail_image_url8 d ,91;0];
- ?>
获取特色图像:中
- <?php
- $medium_image_url = wS i C b d Tp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium');
- echo $C 6 ` U ?medium_image_url[0];
- ?>
获取特色图像:大
- <?php
- $large_image_url = wp_get_attachment_image_! j q . = C S 1 vsrc( get_pos\ z ? z | Qt_thumbj # 9 Snt Y eail_id($post-&gS : \ z K B &t;Iz Z gD), 'large');
- echo $large_image_url[0];
- ?>
获取特色图像:完整
- <?php
- $f7 Y 1 ; ! 4 ~ yull_imZ J + v 5age_url = wp_get_attachment_image_src( get_post_thumbnail_id(\ , 2 X ` a Q$post->ID), 'full');
- echo $full_i/ ( d ~ E I P u Image_url[0];
- ?>
获取特色图像:指定 100x100
- <?php
- $a_ . | q 4 array_image_url = wp_get_attachment_image_src( get_post_thum8 % k obnail_id($post->ID), array(100,19 K c00))g a b G 1 S i ] V;;
- echo $array_image_url[0 & } K E w =0];
- ?>