我想在我的滑動條中顯示特色圖片。所以我在我的function.php做了如下:顯示wordpress滑塊中的特色圖片
<?php
function revconcept_get_images($post_id) {
global $post;
$thumbnail_ID = get_post_thumbnail_id();
$images = get_children(array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
if ($images) :
foreach ($images as $attachment_id => $image) :
$img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); //alt
if ($img_alt == '') : $img_alt = $image->post_title; endif;
$big_array = image_downsize($image->ID, 'large');
$img_url = $big_array[0];
echo '<li>';
echo '<img src="';
echo $img_url;
echo '" alt="';
echo $img_alt;
echo '" />';
echo '</li><!--end slide-->';
endforeach; endif; }
?>
<div class="flexslider"> <!-- function called in index.php -->
<ul class="slides">
<?php revconcept_get_images("$post->ID"); ?>
</ul>
</div><!--end flexslider-->
現在我有兩個問題。 no.1我的精選圖像沒有顯示在滑塊中。它顯示了一個斷開的鏈接。但它可以回顯post_id。 No.2我想只顯示來自cat = 5的最新帖子的3/4圖像。任何人都可以幫我做到這一點?請注意,我爲我的滑塊使用了flexslider。
您嘗試使用DId:'$ thumbnail_ID = get_post_thumbnail_id($ post_id);'? –
剛剛嘗試..不工作。 – Nazmul