WordPress开发者和主题制作者的搜索引擎



add_feed ›

Since2.1.0
已弃用n/a
add_feed ( $feedname, $function )
参数: (2)
  • (string) $feedname Feed name.
    Required: Yes
  • (callable) $function Callback to run on feed display.
    Required: Yes
返回:
  • (string) Feed action name.
定义在:
文档:

Add a new feed type like /atom1/.



Related Functions: do_feed, is_feed, add_filter, add_meta, add_user

源码

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

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

	$hook = 'do_feed_' . $feedname;

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

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

	return $hook;
}