我正在建立两个 wordpress 网站。我在我的第一个站点上有一个自定义 RSS 提要,我想在我的第二个站点上显示自定义字段。这是特色图片。
我可以像这样显示标准字段“title”或“permalink”:“get_title(); ?>”。但无法显示新字段“图像”。
自定义 RSS 是:
<channel>
<title>TITRE CATEGORIE</title>
<atom:link href="http://127.0.0.1/site/feed/" rel="self" type="application/rss+xml" />
<link>http://127.0.0.1/site</link>
<description>DESCRIPTION</description>
<lastBuildDate>Fri, 05 Jul 2019 13:15:21 +0000</lastBuildDate>
<language>fr-FR</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<generator>https://wordpress.org/?v=5.2.2</generator>
<item>
<title>TITRE</title>
<link>http://127.0.0.1/site/page</link>
<pubDate>Wed, 26 Jun 2019 15:56:57 +0000</pubDate>
<dc:creator><![CDATA[gregory]]></dc:creator>
<category><![CDATA[cat-1]]></category>
<category><![CDATA[cat-2]]></category>
<guid isPermaLink="false">http://127.0.0.1/site/?p=56</guid>
<description><![CDATA[<p>L’article <a rel="nofollow" href="http://127.0.0.1/site/page/">Webserie 1</a> est apparu en premier sur <a rel="nofollow" href="http://127.0.0.1/site">NOM DU SITE</a>.</p>
]]></description>
<content:encoded><![CDATA[<p>L’article <a rel="nofollow" href="http://127.0.0.1/site/page/">TITRE</a> est apparu en premier sur <a rel="nofollow" href="http://127.0.0.1/site">NOM DU SITE</a>.</p>
]]></content:encoded>
<image><![CDATA[http://127.0.0.1/site/wp-content/uploads/2019/07/cookies.jpg]]></image>
</item>
我使用此代码来显示 rss :
<?php if(function_exists('fetch_feed')) {
include_once(ABSPATH . WPINC . '/feed.php');
$feed = fetch_feed('http://127.0.0.1/site/tag/musique/feed/');
$limit = $feed->get_item_quantity(1);
$items = $feed->get_items(0, $limit);
} ?>
<?php foreach ($items as $item) : ?>
<?php echo $item->get_title(); ?>
<?php echo $item->get_permalink(); ?>
<?php echo $item->image; ?>
<?php endforeach; ?>
“图像”字段不显示任何内容...如何定位这行项目?感谢您的帮助\o/