是否可以添加自定义帖子wordpress标题的前缀,使其出现在RSS提要和其他共享媒体上?
例如:
自定义帖子类型=产品标题=新茶杯
输出=产品-一个新的茶杯
发布于 2012-09-18 00:34:27
尝试过滤the_title_rss,如果不是post,则添加自定义post类型
function rss_cpt_title($title) {
global $post;
$post_type = get_post_type($post->ID);
if ($post_type != 'post'){
$title = $post_type . ' - ' . $title;
}
return $title;
}
add_filter('the_title_rss', 'rss_cpt_title');您可能需要摆弄条件,因为get_post_type可能会返回一个slug,而且它可能区分大小写。
https://stackoverflow.com/questions/12463392
复制相似问题