2012-08-16 82 views
0

你好我想instegrate滑块到我的wordpress theme.This是我到目前为止有:?检索循环缩略图URL

<?php 
          $slider_query = new WP_Query(array(
             'posts_per_page'=>'5' 
          )); 

          if($slider_query->have_posts()): 
           while($slider_query->have_posts()): 
            $slider_query->the_post(); 
             if(function_exists('has_post_thumbnail') && has_post_thumbnail()){ 
              the_post_thumbnail(); 
             } 
           endwhile; 
          endif; 

>

虽然这工作,并检索图像我需要能够回报url,因为我必须为标题设置不同的标题属性。

任何人都知道的方式来检索缩略图的网址?

编辑:我也tryed使用

$url = wp_get_attachment_image_src(the_post_thumbnail()); 

但SOM原因查询返回10个链接IMG的,我把它设置为5 only.Wierd的事情是,即使图像必须获取URL没有来源。

回答

1

尝试使用wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'wanted-size');。 (用正确尺寸替换wanted-size)。

更多关于get_post_thumbnail_idhere

+0

这将返回一个数组,其['[0]'th索引是源;) – Ben 2015-02-19 20:30:32