函数文档

automatic_feed_links()

💡 云策文档标注

概述

automatic_feed_links() 函数用于启用或禁用自动输出通用 feed 链接,但自 WordPress 3.0 起已被弃用,推荐使用 add_theme_support('automatic-feed-links') 替代。

关键要点

  • 函数 automatic_feed_links() 控制自动 feed 链接的输出,参数 $add 为布尔值,默认为 true 表示启用。
  • 自 WordPress 3.0 版本起,该函数被标记为弃用,应改用 add_theme_support('automatic-feed-links') 来管理主题支持。
  • 函数内部调用 _deprecated_function() 来标记弃用,并根据 $add 值添加或移除相关动作钩子。

代码示例

function automatic_feed_links( $add = true ) {
    _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" );

    if ( $add )
        add_theme_support( 'automatic-feed-links' );
    else
        remove_action( 'wp_head', 'feed_links_extra', 3 );
}

注意事项

  • 在 WordPress 3.0 及以上版本中,应避免使用此函数,转而使用 add_theme_support() 来启用或禁用自动 feed 链接。
  • 函数参数 $add 为可选,默认 true 启用链接,false 则移除 feed_links_extra 动作。

📄 原文内容

Enable/disable automatic general feed link outputting.

Description

See also

Parameters

$addbooloptional
Add or remove links.

Default:true

Source

function automatic_feed_links( $add = true ) {
	_deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" );

	if ( $add )
		add_theme_support( 'automatic-feed-links' );
	else
		remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+.
}

Changelog

Version Description
3.0.0 Deprecated. Use add_theme_support()
2.8.0 Introduced.