rss – Trying to build Google Sitemap feed and it’s downloading instead of displaying in browser
Question
As the title mentions, I’m trying to build a Google News sitemap feed and whenever I go to the /news-sitemap route it downloads a text file.
I’ve tried feed types, “RSS, rss2, and rss-http,” suggested in the docs, https://developer.wordpress.org/reference/functions/feed_content_type/, but it’s still downloading. Not sure what I’m missing. Below is a snippet where I’m defining the urlset and the content type.
Thank you.
<?php
header( 'Content-Type: ' . feed_content_type( 'rss-http' ) . '; charset=" . get_option( "blog_charset' ), true );
$more = 1;
echo '<?xml version="1.0" encoding="' . esc_html( get_option( 'blog_charset' ) ) . '"?' . '>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
0
3 weeks
2022-07-28T13:43:16-05:00
2022-07-28T13:43:16-05:00 0 Answers
0 views
0
Leave an answer