【问题标题】:Why would a Wordpress RSS feed description be limited to 346 characters?为什么将 Wordpress RSS 提要描述限制为 346 个字符?
【发布时间】:2014-05-11 02:52:10
【问题描述】:

不记得曾经见过这个 - 而且似乎找不到类似的问题,所以这里......

我在 WordPress 上设置了一个博客。效果很好。我正在从中提取 RSS2 提要。也很好用。但是,当我迭代提要的输出以设置页面样式时,我发现“描述”节点被截断为 346 个字符,并在末尾添加了“[...]”。

我没有在我的代码中的任何地方这样做。所以我试图找出原因。

这是一个显示提要循环的 sn-p:

foreach ($rss->getElementsByTagName('item') as $node) {
    $item = array (
        'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
        'desc' => trim($node->getElementsByTagName('description')->item(0)->nodeValue),
        'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
        'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
        'postid' => $node->getElementsByTagName('guid')->item(0)->nodeValue,
        'category' => $node->getElementsByTagName('category')->item(0)->nodeValue
    );
    echo $node->getElementsByTagName('description')->item(0)->nodeValue;
    array_push($feed, $item);

您在上面看到的回显仅输出 346 个字符,并在末尾添加“[...]”.. 像这样:

Every day 22 million Americans suffer from uncomfortable acid reflux, according to the International Foundation of Functional Gastrointestinal Disorders. While many people may reach for medications like Proton Pump Inhibitors (PPIs) to provide relief from the effects of acid reflux, a new study from researchers at Kaiser Permanente may leave acid reflux sufferers reconsidering their […]

然而.. 当我查看来自提要的实际内容时,它会显示帖子的整个文本.. 没有限制。 (仅供参考..我添加了修剪功能来做你所期望的 - 消除任何开始或结束的空格。当我删除它时......没有区别。)

所以.. 有人知道我错过了什么吗?

TTAIA

【问题讨论】:

  • 嗯..这个没有人接受?

标签: php wordpress feed rss2


【解决方案1】:

我觉得这个插件(RSS Just Better)对你有帮助

你可以轻松管理

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 2012-08-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多