내 게시물에 3 개의 이미지가 첨부되어 있습니다. 3 개의 이미지 URL을 3 개의 개별 변수로 바꾸고 배경 이미지를 css
에 사용하고 싶습니다. 지금까지 3 개의 URL을 표시 할 수 있었지만 변수를 배경 이미지로 지정할 수는 없습니다.Wordpress attachment urls을 변수로 사용
if ($attachments = get_children(array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
)));
foreach ($attachments as $attachment) {
$mynewarray = wp_get_attachment_image_src($attachment->ID, 'rig');
$anotherarray = $mynewarray[0];
echo $anotherarray ;
}
위의 결과는 here입니다.
어떻게 분리하여 $backgroundimage1, $backgroundimage2 & $backgroundimage3
과 같이 변수로 변환 할 수 있습니까? 그래서 나는 페이지에서 나중에 전화 할 수 있습니다.
<div class="backgound-image" style="background-image: url(<?php echo $backgroundimage1 ?>)">
도움을 주신 덕분에 다음 번에 내 서식이 개선되었습니다. 감사합니다. – Stephen