2012-10-11 42 views
0

我正在創建自己的自定義wordpress主題。發佈縮略圖無法在wordpress主題上工作

這是我的主題的index.php文件有:

<?php while (have_posts()) : the_post(); ?> 
     <li id="post-<?php the_ID(); ?>"> 
      <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> 
      </span> 
      <?php if (has_post_thumbnail()) : ?> 
       <a href="<?php the_permalink(); ?>" class="thumb"><img src="<?php the_post_thumbnail(); ?>" /></a> 
      <?php endif; ?> 
      <div class="post"> 
       <?php get_the_content(400, "Read more"); ?> <a href="<?php the_permalink(); ?>">Read more</a>. 
      </div<br/> 

我functions.php文件有這樣的:

<?php 

add_theme_support('post-thumbnails', array('post')); 
the_post_thumbnail(array(80,80)); 

?> 

我的網站顯示,這(圖像不加載):

<a href="http://ipadappbuzz.com/?p=1" class="thumb"><img src="<img width="50" height="50" src="http://ipadappbuzz.com/wp-content/uploads/article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800-50x50.jpg" class="attachment-post-thumbnail wp-post-image" alt="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" title="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" />" /></a> 
          <div class="post"> 
       <a href="http://ipadappbuzz.com/?p=1">Read more</a>. 

不確定爲什麼圖像源無法正確加載。

回答

1

你的問題是,你必須指向另一個IMG的字符串定義的IMG SRC屬性:

<a href="http://ipadappbuzz.com/?p=1" class="thumb"><img src="<img width="50" height="50" src="http://ipadappbuzz.com/wp-content/uploads/article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800-50x50.jpg" class="attachment-post-thumbnail wp-post-image" alt="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" title="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" />" /></a> 
          <div class="post"> 
       <a href="http://ipadappbuzz.com/?p=1">Read more</a>. 

這是有問題的行:

<img src="<img width="50" height="50" src="http://ipadappbuzz.com/wp-content/uploads/article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800-50x50.jpg" class="attachment-post-thumbnail wp-post-image" alt="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" title="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" />" /> 

它需要被修正到以下 - 或者這樣的效果:

<img width="50" height="50" src="http://ipadappbuzz.com/wp-content/uploads/article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800-50x50.jpg" class="attachment-post-thumbnail wp-post-image" alt="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" title="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" /> 

現在,至於代碼,我的發電這樣的:

<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> 

我不知道是什麼the_permalink()the_title_attribute(),或the_title()功能,以及如何你定義他們,他們返回的內容。 但是,我的懷疑是你已經在的地方引入了額外的結束標籤。

UPDATE:

從代碼中原來的海報已與更新,我想你應該有你的PHP代碼如下:

「類=」 拇指 「>」

因爲它似乎好像the_post_thumbnail()回顯/返回一個img:

<img width="50" height="50" src="http://ipadappbuzz.com/wp-content/uploads/article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800-50x50.jpg" class="attachment-post-thumbnail wp-post-image" alt="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" title="article-new_ehow_images_a00_05_uu_decorate-outdoors-halloween-800x800" /> 
+0

那麼我在我的主題文件中的代碼是: <如果PHP(has_post_thumbnail()):?>? \t \t \t \t \t \t \t \t \t 所以它應該解析並加載這樣的源代碼:但由於某種奇怪的原因,圖像代碼複製並將其放置在另一個現有圖像代碼中,我試圖找出原因。 – user1114968

+0

如果可能,你可以發佈嗎? – jrd1

+0

我很快就按下了輸入按鈕。閱讀我的回覆。 – user1114968

相關問題