이 게시물워드 프레스의 첫 번째 이미지의 다른 속성 게시 받기
function get_first_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "/images/default.jpg";
}
return $first_img;
}
이 만 SRC를 반환에서 첫 번째 이미지를 얻기 위해 일반적으로 사용되는 함수가 될 것으로 보인다. 하나의 배열에 해당 이미지의 제목, 캡션 및 설명을 반환하려면이 확장이 필요합니다. 어떻게 할 수 있습니까 ??
시도해보십시오. http://www.rlmseo.com/blog/get-images-attached-to-post/ –