Skip to content

Instantly share code, notes, and snippets.

Created August 24, 2023 15:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
mu-plugin for /.well-known/feeds
Plugin Name: Custom OPML Feed
Description: Implements a custom OPML feed at /.well-known/feeds/
Author: cagrimmett
// Add custom rewrite rule
function custom_opml_rewrite_rule() {
add_rewrite_rule( '^\.well-known/feeds/?$', 'index.php?custom_opml_feed=1', 'top' );
add_action( 'init', 'custom_opml_rewrite_rule' );
// Add custom query variable
function custom_opml_query_vars( $query_vars ) {
$query_vars[] = 'custom_opml_feed';
return $query_vars;
add_filter( 'query_vars', 'custom_opml_query_vars' );
// Serve OPML file
function serve_custom_opml_feed() {
if ( get_query_var( 'custom_opml_feed' ) ) {
$opml_file_path = ''; // Replace with your actual file path
header( 'Content-Type: text/x-opml' );
readfile( $opml_file_path );
add_action( 'template_redirect', 'serve_custom_opml_feed' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment