[wp-trac] [WordPress Trac] #36334: Custom RSS feed has wrong MIME type and forces download in browser
WordPress Trac
noreply at wordpress.org
Sun Apr 17 19:57:28 UTC 2016
#36334: Custom RSS feed has wrong MIME type and forces download in browser
--------------------------+-----------------------
Reporter: Missilesilo | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone:
Component: Feeds | Version: 2.1
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+-----------------------
Comment (by swissspidy):
Ignore my previous comment. I just had another look at this and couldn't
find any problem.
{{{#!php
<?php
// Example A:
function trac_36334_add_superfeed() {
add_feed( 'superfeed', 'trac_36334_superfeed_cb' );
}
add_action( 'init', 'trac_36334_add_superfeed' );
function trac_36334_superfeed_cb() {
header( 'Content-Type: text/html' );
echo 'Do something...';
}
}}}
{{{#!php
<?php
// Example B:
function trac_36334_add_superduperfeed() {
add_feed( 'superduperfeed', 'trac_36334_superduperfeed_cb' );
}
add_action( 'init', 'trac_36334_add_superduperfeed' );
function trac_36334_superduperfeed_cb() {
header( 'Content-Type: text/html' ); // or any other content type
echo 'Do something...';
}
function trac_36334_superduperfeed_type( $content_type, $type ) {
if ( 'superduperfeed' === $type ) {
return feed_content_type( 'rss2' );
}
return $content_type;
}
add_filter( 'feed_content_type', 'trac_36334_superduperfeed_type', 10, 2
);
}}}
Both examples work as expected running WordPress 4.5 and no additional
plugins.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36334#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list