feed_content_type

Return the content type for specified feed type.

Description

feed_content_type( (string) $type = '' ); 

Parameters (1)

0. $type — Optional. (string) => ''
Type of feed. Possible values include rss,, rss2', atom., and rdf.

Usage

  1. if ( !function_exists( 'feed_content_type' ) ) { 
  2. require_once ABSPATH . WPINC . '/feed.php'; 
  3.  
  4. // Type of feed. Possible values include 'rss', rss2', 'atom', and 'rdf'. 
  5. $type = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = feed_content_type($type); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/feed.php  
  1. function feed_content_type( $type = '' ) { 
  2. if ( empty($type) ) 
  3. $type = get_default_feed(); 
  4.  
  5. $types = array( 
  6. 'rss' => 'application/rss+xml',  
  7. 'rss2' => 'application/rss+xml',  
  8. 'rss-http' => 'text/xml',  
  9. 'atom' => 'application/atom+xml',  
  10. 'rdf' => 'application/rdf+xml' 
  11. ); 
  12.  
  13. $content_type = ( !empty($types[$type]) ) ? $types[$type] : 'application/octet-stream'; 
  14.  
  15. /** 
  16. * Filters the content type for a specific feed type. 
  17. * @since 2.8.0 
  18. * @param string $content_type Content type indicating the type of data that a feed contains. 
  19. * @param string $type Type of feed. Possible values include 'rss', rss2', 'atom', and 'rdf'. 
  20. */ 
  21. return apply_filters( 'feed_content_type', $content_type, $type );