how can I set content-type text/xml for xml RSS feed?

Viewed 49

can I set content type text/XML of creating a file in WordPress without changing htacess file?

header('Content-Type: text/xml;charset='.get_option('blog_charset'), true);
$my_file =fopen("rss_feed.xml", "w");
$file_contents .= '<?xml version="1.0"?><rss version="2.0">'; 
$file_contents .='<channel>';
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
    while ($post_query-> have_posts() ) :
        $post_query->the_post();
        $file_contents .= '<item><title>' . get_the_title_rss().'</title>' ;
        $file_contents .='</item>';
    endwhile;
}
$file_contents .='</channel></rss>';
fwrite($my_file, $file_contents);
fclose($path);
0 Answers
Related