Slayt gösterisi türünde bir gönderime eklenen görüntüleri tek tek göstermek için resim eki sayfasını kullanıyorum. Resim ve kelime "Resim 3/15" kelimelerini görebilmeniz için, herhangi bir ek sayfada görüntülenen belirli görüntünün sayısını ve ana gönderiye eklenen toplam görüntü sayısını görüntüleyebilmek istiyorum Örneğin. Hala geçerli görüntünün sayısını göstermek için nasıl bilemiyorumResim eki sayfasındaki bir gönderiye eklenen görüntülerin sayısını nasıl gösteririm?
<?php
global $post;
$attachments = get_children(array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
$count = count($attachments);
echo $count;
?>
:
Güncelleme ... Bu kodu kullanarak göstermek için toplam sayısını elde edebildi.
Herhangi bir öneriniz var mı?
Güncelleme 2 ...
Greenie cevabı neredeyse san bakalım ama bir kerede tüm sayılar çıktısı oluyor:
kullandığım kodu 8" 8Image 8 nin 8Image 7:"Resim 1 8Image 2 8Image 3 arasında 8Image 4 8Image 6 8Image 5 İşte
global $post;
$attachments = get_children(array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
$count = count($attachments);
$currentImage = 1;
foreach ($attachments as $attachment) {
// output your image here
echo "Image ". $currentImage . " of ". $count;
$currentImage++;
}
Neler oluyor?
Güncelleştirme 3 - CEVAP!
global $post;
$attachments = get_children(array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
$count = count($attachments);
$specific = array();
$i = 1;
foreach ($attachments as $attachment) {
$specific[$attachment->ID] = $i;
++$i;
}
echo "Image {$specific[$post->ID]} of {$count}";
Teşekkür resimlerinizin sırasını değiştirebilir. Bu beni neredeyse oradan aldı. Yukarıdaki soruyu güncel sorunla güncelledim. – mattz