wpseek.com
A WordPress-centric search engine for devs and theme authors



add_feed › WordPress Function

Since2.1.0
Deprecatedn/a
add_feed ( $feedname, $callback )
Parameters: (2)
  • (string) $feedname Feed name.
    Required: Yes
  • (callable) $callback Callback to run on feed display.
    Required: Yes
Returns:
  • (string) Feed action name.
Defined at:
Codex:

Adds a new feed type like /atom1/.



Source

function add_feed( $feedname, $callback ) {
	global $wp_rewrite;

	if ( ! in_array( $feedname, $wp_rewrite->feeds, true ) ) {
		$wp_rewrite->feeds[] = $feedname;
	}

	$hook = 'do_feed_' . $feedname;

	// Remove default function hook.
	remove_action( $hook, $hook );

	add_action( $hook, $callback, 10, 2 );

	return $hook;
}