WordPress:需要更改RSS提要中的帖子永久链接URL


WordPress: Need to change post permalink URL in RSS feed

出于某种原因,我需要稍微更改一下我的WP博客的RSS提要的URL。目前,永久链接如下所示:

http://www.thesite.com/blogs/post_title

这也是进入我的RSS提要(我构建的自定义提要)的URL。但是,我需要 URL 与博客而不是博客一起使用

http://www.thesite.com/blog/post_title

为此,这是我尝试在我的自定义提要PHP(rss-burrofeed.php)代码中使用带有WP the_permalink_rss()str_replace()函数的,以下是在上下文中说明此技巧的代码片段:

   <item>
        <title><?php the_title_rss(); ?></title>
        <link><?php str_replace('/blogs/','/blog/',the_permalink()); ?></link>
        <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
         <dc:creator><?php the_author(); ?></dc:creator>
         <guid isPermaLink="false"><?php the_guid(); ?></guid>
         <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
         <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
         <?php rss_enclosure(); ?>
         <?php do_action('rss2_item'); ?>
</item>

但这行不通。这些链接仍然出现在博客而不是博客中。我做错了什么吗?为什么str_replace()不起作用?

可能

比函数 the_permalink() 生成其他信息,因为我试图找到我

    $phrase  = "http://www.thesite.com/blogs/post_title";
    $newphrase = str_replace('/blogs/','/blog/',$phrase);
    print_R($phrase);
    print_R('<br>');
    print_R($newphrase);

并打印:


http://www.thesite.com/blogs/post_titlehttp://www.thesite.com/blog/post_title

参数是字符串,我认为比函数不给数据相等!