排除部分 wordpress post 出现在 rss 提要中
Exclude part of a wordpress post from appearing the rss feed
我想排除几行大多数 wordpress posts 出现在 rss 提要中。
例如,如果我的 post 正文是
<embed>Some file</embed>
Hello World
如何排除 <embed>Some file</embed>
出现在 Feed 中。
要完成此操作,您应该在将 post 发送到 RSS 提要之前使用过滤器删除不需要的元素。
将此添加到您的 functions.php 以注册函数:
<?php add_filter( "the_content_feed", "filter_away_embed_function" ) ?>
将以下代码添加到插件或 functions.php 中:
<?php
function filter_away_embed_function($content) {
$content = preg_replace('#(<embed.*?>).*?(</embed>)#', '', $content)
return $content;
} ?>
该函数将删除 <embed>
和 </embed>
内的所有文本。
我想排除几行大多数 wordpress posts 出现在 rss 提要中。
例如,如果我的 post 正文是
<embed>Some file</embed>
Hello World
如何排除 <embed>Some file</embed>
出现在 Feed 中。
要完成此操作,您应该在将 post 发送到 RSS 提要之前使用过滤器删除不需要的元素。
将此添加到您的 functions.php 以注册函数:
<?php add_filter( "the_content_feed", "filter_away_embed_function" ) ?>
将以下代码添加到插件或 functions.php 中:
<?php
function filter_away_embed_function($content) {
$content = preg_replace('#(<embed.*?>).*?(</embed>)#', '', $content)
return $content;
} ?>
该函数将删除 <embed>
和 </embed>
内的所有文本。