钩子文档

login_headerurl

💡 云策文档标注

概述

“login_headerurl”过滤器用于修改WordPress登录页面上方Logo的链接URL。默认情况下,此Logo链接到WordPress站点,开发者可以通过此过滤器自定义链接目标。

关键要点

  • 过滤器名称:login_headerurl,用于过滤登录页头Logo的URL。
  • 参数:$login_header_url(字符串类型),表示登录页头Logo的URL。
  • 应用方式:可通过插件或主题的functions.php文件使用add_filter()注册过滤器函数。
  • 注意事项:过滤器函数必须返回处理后的URL,否则可能导致链接丢失或与其他插件冲突。

代码示例

/**
 * Custom login image URL
 */
function my_custom_login_url( $url ) {
	return get_bloginfo( 'url' );
}
add_filter( 'login_headerurl', 'my_custom_login_url', 10, 1 );

📄 原文内容

Filters link URL of the header logo above login form.

Parameters

$login_header_urlstring
Login header logo URL.

More Information

The “login_headerurl” filter is used to filter the URL of the logo on the WordPress login page. By default, this logo links to the WordPress site.

A plugin can register as a content filter with the code:

add_filter("login_headerurl","plugin_function_name");

Where “plugin_function_name” is the function WordPress should call when the content is being retrieved. Note that the filter function the plugin defines must return the URL after it is finished processing, or the logo may not have any links, and other plugins also filtering the same may generate errors.

You can also use this in the theme function.php file within your WordPress page if you don’t wish to use a plugin or want to distribute your theme.

Source

$login_header_url = apply_filters( 'login_headerurl', $login_header_url );

Changelog

Version Description
2.1.0 Introduced.

User Contributed Notes