0

我正在创建自己的自定义 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>.

不知道为什么图像源没有正确加载。

4

1 回答 1

1

您的问题是您的 img src 属性指向另一个 img 的字符串定义:

<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()函数是什么,以及您如何定义它们以及它们返回什么。但是,我怀疑你在某处引入了一个额外的结束标签

更新:

从原始海报更新我的代码来看,我认为您的 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" />
于 2012-10-11T03:21:12.360 回答