我已经在非常简单的播客插件中对以下文件做了如下更改:
/wp-content/plugins/seriously-simple-podcasting/templates/feed-podcast.php
完整的文件可以在这里找到:https://github.com/TheCraigHewitt/Seriously-Simple-Podcasting/blob/master/templates/feed-podcast.php
// iTunes summary is the full episode content, but must be shorter than 4000 characters
$itunes_summary = mb_substr( $content, 0, 3999 );
$itunes_summary = apply_filters( 'ssp_feed_item_itunes_summary', $itunes_summary, get_the_ID() );
$gp_description = apply_filters( 'ssp_feed_item_gp_description', $itunes_summary, get_the_ID() );至:
// iTunes summary is the full episode content, but must be shorter than 4000 characters
ob_start();
the_excerpt_rss();
$itunes_summary = mb_substr( ob_get_clean(), 0, 3999 );
$itunes_summary = apply_filters( 'ssp_feed_item_itunes_summary', $itunes_summary, get_the_ID() );
$gp_description = apply_filters( 'ssp_feed_item_gp_description', $itunes_summary, get_the_ID() );原因是我希望RSS提要模板中的itunes :汇总标记从摘录中提取,而不是从post内容中提取,这样我们就可以更好地控制itunes摘要。
然而,我知道这样做会阻止我更新我不想要的插件,我还读过关于创建一个功能插件的文章,但是我不确定如何创建这个插件来编辑该文件,因为我以前没有做过太多PHP,也没有玩过wordpress代码。
有人能帮忙/建议吗?
发布于 2019-01-29 09:02:57
这就是ssp_feed_item_itunes_summary过滤器的用途。它允许您通过一个单独的插件/函数来更改该值。您可以阅读更多关于过滤器这里的信息。
因此,与其进行编辑,不如向ssp_feed_item_itunes_summary添加一个筛选器:
function wpse_326975_itunes_summary( $itunes_summary, $post_id ) {
$itunes_summary = get_the_excerpt( $post_id );
return $itunes_summary;
}
add_filter( 'ssp_feed_item_itunes_summary', 'wpse_326975_itunes_summary', 10, 2 );https://wordpress.stackexchange.com/questions/326975
复制相似问题