add_feed

Add a new feed type like /atom1/.

Description

(string) add_feed( (string) $feedname, (callable) $function ); 

Returns (string)

Feed action name.

Parameters (2)

0. $feedname (string)
The feedname.
1. $function (callable)
Callback to run on feed display.

Usage

  1. if ( !function_exists( 'add_feed' ) ) { 
  2. require_once ABSPATH . WPINC . '/rewrite.php'; 
  3.  
  4. // The feedname. 
  5. $feedname = ''; 
  6.  
  7. // Callback to run on feed display. 
  8. $function = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = add_feed($feedname, $function); 
  12.  

Defined (1)

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

/wp-includes/rewrite.php  
  1. function add_feed( $feedname, $function ) { 
  2. global $wp_rewrite; 
  3.  
  4. if ( ! in_array( $feedname, $wp_rewrite->feeds ) ) { 
  5. $wp_rewrite->feeds[] = $feedname; 
  6.  
  7. $hook = 'do_feed_' . $feedname; 
  8.  
  9. // Remove default function hook 
  10. remove_action( $hook, $hook ); 
  11.  
  12. add_action( $hook, $function, 10, 2 ); 
  13.  
  14. return $hook;