2012-10-15 64 views
1

我製作了一個單獨的wordpress頁面來顯示我所有的精選圖片,但他們確實顯示,但我需要幫助他們如何使其顯示爲實際大小而不是真正的小圖片。在wordpress頁面上更改文章縮略圖大小

<?php 
$the_query = new WP_Query(); 
$the_query->query("cat=4&nopaging=true"); 

if ($the_query->have_posts()) : 
while($the_query->have_posts()) : $the_query->the_post(); 

    if(has_post_thumbnail()) : 
    the_post_thumbnail(); 
    endif; 

endwhile; 
endif; 
wp_reset_postdata(); 
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); 
?> 

<img src='<?php echo $image[0]; ?>' /> 

這是我的代碼,現在的頁面是http://rickwarren.veracitycolab.com/banners/

謝謝!

這是我的新代碼看起來像和圖像仍然是任何想法?

<?php 
$the_query = new WP_Query(); 
$the_query->query("cat=4&nopaging=true"); 
if ($the_query->have_posts()) : 
while($the_query->have_posts()) : $the_query->the_post(); 

    if(has_post_thumbnail()) : 
    the_post_thumbnail(); 
    endif; 

endwhile; 
endif; 
wp_reset_postdata(); 
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); 
?> 

回答

1

wp_get_attachment_image_src()的第二個參數是要返回的圖像的大小。使用full這裏應該給你全尺寸的圖像。

$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); 

編輯:當然你的這部分代碼沒有做任何事情,因爲它是在循環外。

變更線8 the_post_thumbnail('full');

可以與$image...開頭的行後刪除所有內容。 Codex page here

+0

我剛剛添加了更改,但仍然沒有運氣,對此有何看法? – jrojas

+0

看我上面的編輯。 – cpilko

+0

謝謝!我的錯。 :) – jrojas

1

通過wp_get_attachment_image_src(...)大小參數。在你的情況下,你想'滿',所以wp_get_attachment_image_src($post->ID, 'full')。從the Codex for that function

$大小 (串/陣列)用於圖像附件所示的圖像的(可選)尺寸:一個字符串的關鍵字(縮略圖,中型,大型或全部) 或2-項數組以像素爲單位表示寬度和高度,例如 數組(32,32)。從2.5版開始,此參數不會影響媒體圖標的大小,它們始終以原始大小顯示。

Default: thumbnail 

CSS規則仍然會「縮水」的形象雖然如此,如果它不工作查詢的網址在HTML源代碼,以確認正在請求正確的圖像,然後檢查樣式表。

+0

讓我試試這個謝謝! – jrojas

+0

我檢查了樣式表並插入了更改(玩過不同的尺寸和代碼),但仍然沒有運氣。任何更多的想法或我應該檢查的東西? – jrojas

+0

您是否檢查過以確保「完整​​」尺寸圖像正確?也就是說,你是否「檢查HTML源代碼中的URL以確認正在請求正確的圖像」? –

相關問題