0

我一直在玩弄我网站的 function.php 以在我的提要中显示图像。图像看起来很好,但图像后面出现了这个“数组”文本。老实说,这超出了我的范围,因为我只是这个 php 代码的新手。希望这里有人对此有答案。

我的function.php代码是:

function featuredtoRSS($content) {
    global $post;
    $image = wp_get_attachment_image_src(get_field('image_1'));
    ?>
    <img class="entry-thumb wp-post-image" width="80px" style="float:left" src="<?php echo $image[0]; ?>" alt="<?php get_the_title(get_field('image_1')) ?>" />
    <?php { $content = '' . $image . '' . $content; }
    return $content;
}

add_filter('the_excerpt_rss', 'featuredtoRSS');

我使用 wordpress 3.3.1 这是我的提要的样子(请参阅图像和内容之间的“数组”文本) http://autonewsmedia.com/feed

4

1 回答 1

0

明白了,把代码改成:

function featuredtoRSS($content) {
global $post;
$image = wp_get_attachment_image_src(get_field('image_1')); ?>
<img src="<?php echo $image[0]; ?>" alt="<?php get_the_title(get_field('image_1')) ?>" />
<?php return $content;
}
add_filter('the_excerpt_rss', 'featuredtoRSS');

希望它对其他人有帮助。

于 2012-04-09T11:48:55.297 回答