add_feed

Advertisement

Summery Summery

Add a new feed type like /atom1/.

Syntax Syntax

add_feed( string $feedname, callable $function )

Parameters Parameters

$feedname

(string) (Required) Feed name.

$function

(callable) (Required) Callback to run on feed display.

Return Return

(string) Feed action name.

Source Source

File: wp-includes/rewrite.php

function add_feed( $feedname, $function ) {
	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, $function, 10, 2 );

	return $hook;
}

Advertisement

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.