我正在创建自己的自定义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>.
不确定图像源未正确加载的原因。
答案 0 :(得分: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代码:
“class =”thumb“&gt;”
因为似乎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" />