, wenn ich versuche, get_the_ID() innerhalb get_attached_file() zu verwenden i immer leer Antwort Beispiel get_attached_file(get_the_ID())
Fehler bei der Verwendung get_the_id in innen get_attached_file Wordpress
bekommen, aber wenn ich wie get_attached_file(4125)
normale Zahl verwenden ihre Arbeit totaly
was sollte ich tun, um es zu reparieren?
meinen Code jetzt:
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");
// First we get the image id
// $post_thumbnail_id = get_post_thumbnail_id(get_the_ID());
// // Then we get the image data, we will get an array with some informations
// $image = wp_get_attachment_image_src($post_thumbnail_id, 'large');
// // the image url is the first index of this array
// $image_url = $image[0];
$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" => basename(get_attached_file($post_id)),
);
endwhile;
endif;
echo json_encode($meta);
break;
ich es versucht habe, bevor ich mein Problem zu veröffentlichen, und in der Tat die Spitzen u mir seine nicht funktioniert geben, dazu noch andere Lösung? –