내 자신의 방식으로 wp_attachment_metadata를 가져오고 싶습니다. 나는 파일 이름을 얻고 싶다 :wp_attachment_metadata에서 메타 값을 얻는 방법
a:5:{s:5:"width";i:500;s:6:"height";i:500;s:4:"file";s:25:"2016/08/sprite_1500ml.jpg";s:5:"sizes";a:5:{s:9:"thumbnail";a:4:{s:4:"file";s:25:"sprite_1500ml-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:25:"sprite_1500ml-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}s:14:"shop_thumbnail";a:4:{s:4:"file";s:25:"sprite_1500ml-180x180.jpg";s:5:"width";i:180;s:6:"height";i:180;s:9:"mime-type";s:10:"image/jpeg";}s:12:"shop_catalog";a:4:{s:4:"file";s:25:"sprite_1500ml-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}s:11:"shop_single";a:4:{s:4:"file";s:25:"sprite_1500ml-400x400.jpg";s:5:"width";i:400;s:6:"height";i:400;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}
글쎄, 나는 붙어있다. 해당 배열을 분리하는 방법을 모르겠습니다. 누구든지 파일 이름 (URL 파일)을 얻을 수 있도록 배열을 분리하는 방법을 알고 있습니다. 지금
내 코드 :
$command = $_GET['command'];
switch ($command) {
case 'list_product':
$loop = new WP_Query(
array(
'post_type' => 'product'
)
);
if($loop->have_posts()) :
$data = array("api_status" => 1, "api_message" => "success");
$meta = array();
while ($loop->have_posts()) : $loop->the_post();
$meta[] = array(
"id" => get_the_ID(),
"post_name" => get_the_title(),
"stock_status" => get_post_meta(get_the_ID(), '_stock_status', true),
"price" => get_post_meta(get_the_ID(), '_price', true),
"reguler_price" => get_post_meta(get_the_ID(), '_regular_price', true),
"image" => get_post_meta(get_the__ID(), '_wp_attachment_metadata', true),
);
endwhile;
endif;
echo json_encode($meta);
break;
내가 사용할 때 내 말 :
이"image" => get_post_meta(get_the__ID(), '_wp_attachment_metadata', true),
내 결과가 무엇이든에게
을 보여 나던 내 코드에서 무엇을 개선 그래서 그 캔 작업 내가 원하는 걸 좋아해?
어쩌면 [이 게시물] (http://wordpress.stackexchange.com/questions/18463/how-to-extract-data-from-a-post-meta-serialized-array) 도움이됩니다. –
iam 미안 해요, 처음에''image "=> get_post_meta (get_the__ID(), '_wp_attachment_metadata', true)를 사용하면'doest는 데이터를 보여 줍니 다. –