Change Wordpress feed <link> for one specific tag -
i have external page reads rss feed tag. can't change on external page, challenge change rss feed on side match requirements. on external page 3 latest posts tag shown, , @ end of section (note: not after each post after 3 posts) there "view all" link. link receives value element in feed, default set blog homepage, e.g. http://myblog.com). specific tag link should http://myblog.com/tag/myspecialtag.
the requirement "view all" link links tag page instead of homepage.
my idea add condition element change url specific category. tried change feed template recommended here: customizing feeds, reason doesn't change template @ all. code tried following:
remove_all_actions( 'do_feed_rss2' ); add_action( 'do_feed_rss2', 'change_feed_rss2', 10, 1 ); function change_feed_rss2( $for_comments ) { $rss_template = get_template_directory() . '/feeds/feed-custom_rss2.php'; if( file_exists( $rss_template ) ) load_template( $rss_template ); else do_feed_rss2( $for_comments ); // call default function } of course created custom feed template , stored in feeds directory in theme.
as didn't work tried looking filters/hooks couldn't find helpful regarding issue. ideas on how best solve issue?
i came following solution: created new custom page template custom_rss-feed.php , copied code wp-includes/feed-rss.php it. assigned template new page. additionally added filter get_bloginfo_rss following:
function alter_bloginfo_rss($value, $key) { if ( $key === "url" && is_page_template("custom_rss-feed.php") ) { return $value . "/my/custom/url"; } return $value; } add_filter("get_bloginfo_rss", "alter_bloginfo_rss", 10, 2);
Comments
Post a Comment