由於某些原因,我需要對使用WP動力博客的RSS源發佈的網址進行輕微更改。目前,永久鏈接是這樣的:WordPress:需要更改RSS源中的帖子永久鏈接網址
http://www.thesite.com/blogs/post_title
這是怎麼回事了我的RSS飼料(定製飼料我建),以及網址。不過,我需要的URL一起去的博客而不是博客:
http://www.thesite.com/blog/post_title
爲此,這就是我嘗試使用str_replace()
功能與WP的the_permalink_rss()
在我的自定義飼料PHP(RSS -burrofeed.php)代碼和這裏的說明在此範圍內的黑客片段:
<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()
正常工作?