Last active
August 16, 2023 09:08
-
-
Save eudesgit/ac33d97c670e009b1aba8bc4238203d9 to your computer and use it in GitHub Desktop.
How to generate custom RSS on WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generating your own custom RSS feed with custom URL and parameters | |
*/ | |
/** | |
* Initialise RSS feed | |
* @see https://developer.wordpress.org/reference/functions/add_feed/ | |
*/ | |
function init_rss_feed_custom( ) { | |
add_feed('feed_name', 'add_rss_feed_custom'); | |
} | |
add_action('init', 'init_rss_feed_custom'); | |
/** | |
* Generates Events Master List Feed RSS | |
* URL: /feed/?feed=alg_events_master_list | |
* | |
* @see https://developer.wordpress.org/reference/functions/add_feed/ | |
*/ | |
function add_rss_feed_custom ( ) { | |
header('Content-Type: application/rss+xml'); | |
?> | |
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | |
<channel> | |
<title><?php bloginfo_rss('title') ?></title> | |
<link><?php bloginfo_rss('url') ?></link> | |
<description><?php bloginfo_rss('description') ?></description> | |
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> | |
<item> | |
<description> | |
<![CDATA["Jesus is the LORD"]]> | |
</description> | |
<pubDate>Fri, 08 Nov 2019 01:56:02 GMT</pubDate> | |
<guid>https://www.website.com/post/1</guid> | |
</item> | |
</channel> | |
</rss> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment