2014-03-12 189 views
-1

我已經創建了一個自定義的帖子類型,它通過一個插件彈出。 但是圖像沒有出現在彈出窗口中,所以我想在href標籤中調用圖像,我不知道如何調用它。如何在href標籤中獲得wordpress特色圖片

有一些代碼

<?php 
    $args = array('post_type' => 'Gallery', 'posts_per_page' => All); 
    $loop = new WP_Query($args); 
    while ($loop->have_posts()) : $loop->the_post(); 
    echo '<div class="thumbnail-container"><div class="thumbnail-wrap"><a title"" rel="lightbox" href="#" >'; 
    the_post_thumbnail(full); 
    echo '</a><div class="thumbnail-containt">'; 
    the_content(); 
    echo '</div></div></div>'; 
    endwhile; 
    ?> 

回答

1
<?php 
    $args = array('post_type' => 'Gallery', 'posts_per_page' => All); 
    $loop = new WP_Query($args); 
    while ($loop->have_posts()) : $loop->the_post(); 
    $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); 
    echo '<div class="thumbnail-container"><div class="thumbnail-wrap"><a title"" rel="lightbox" href="'.$large_image_url[0].'" >'; 
    the_post_thumbnail(full); 
    echo '</a><div class="thumbnail-containt">'; 
    the_content(); 
    echo '</div></div></div>'; 
    endwhile; 
?> 

Replac e此代碼​​。

+0

感謝pranita,一爲你:) –

0

我覺得你應該嘗試

$imageUrl = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'thumbnail')); 
<img src="<?php echo $imageUrl; ?>" /> 
0

使用wp_get_attachment_image_src獲得圖像URL

<?php 
$args = array('post_type' => 'Gallery', 'posts_per_page' => All); 
    $loop = new WP_Query($args); 
    while ($loop->have_posts()) : $loop->the_post(); 
    $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); 

    echo '<div class="thumbnail-container"><div class="thumbnail-wrap"><a title="" rel="lightbox" href="$image" >'; 
    the_post_thumbnail(full); 
    echo '</a><div class="thumbnail-containt">'; 
    the_content(); 
    echo '</div></div></div>'; 
    endwhile; 

?> 
0

您的title標籤也許?

變化title""title=""

<?php 
    $args = array('post_type' => 'Gallery', 'posts_per_page' => All); 
    $loop = new WP_Query($args); 
    while ($loop->have_posts()) : $loop->the_post(); 
    echo '<div class="thumbnail-container"><div class="thumbnail-wrap"><a title="" rel="lightbox" href="#" >'; 
    the_post_thumbnail(full); 
    echo '</a><div class="thumbnail-containt">'; 
    the_content(); 
    echo '</div></div></div>'; 
    endwhile; 
    ?>