get_search_feed_link()获取一个搜索Feed订阅网址

目录

描述

译文

在搜索结果中检索feed的永久链接

原文

Retrieve the permalink for the feed of the search results.

get_search_feed_link() 描述

用法

<?php echo get_search_feed_link$search_query$feed ?>

If you don't echo the function you're simply going to get a permalink to the page with no RSS feed for the search results.

get_search_feed_link() 用法

参数

$search_query

(string) (可选) URL search query.

默认值: ''

$feed

(string) (可选) Feed type.

默认值: ''

get_search_feed_link() 参数

返回值

(string) 

Returns a url after the 'search_feed_link' filters have been applied.

get_search_feed_link() 返回值

注意

get_search_feed_link() 注意

历史

添加于 版本: 2.5.0

get_search_feed_link() 历史

源文件

get_search_feed_link() 函数的代码位于 wp-includes/link-template.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Retrieve the permalink for the feed of the search results.
 *
 * @since 2.5.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string $search_query Optional. Search query.
 * @param string $feed         Optional. Feed type.
 * @return string The search results feed permalink.
 */
function get_search_feed_link($search_query = '', $feed = '') {
	global $wp_rewrite;
	$link = get_search_link($search_query);

	if ( empty($feed) )
		$feed = get_default_feed();

	$permastruct = $wp_rewrite->get_search_permastruct();

	if ( empty($permastruct) ) {
		$link = add_query_arg('feed', $feed, $link);
	} else {
		$link = trailingslashit($link);
		$link .= "feed/$feed/";
	}

	/**
	 * Filter the search feed link.
	 *
	 * @since 2.5.0
	 *
	 * @param string $link Search feed link.
	 * @param string $feed Feed type.
	 * @param string $type The search type. One of 'posts' or 'comments'.
	 */
	return apply_filters( 'search_feed_link', $link, $feed, 'posts' );
}

get_search_feed_link() 源文件