WordPress主题开发:开启feed功能

开启feed功能

步骤一:
在模版文件的<head></head>元素中添加wp_head()函数,且wp_head()函数要放在</head>标签之前,而且紧邻</head>标签,如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>开启feed功能</title>
<?php wp_head();?>
</head>

<body>
</body>
</html>

步骤二:
在主题的functions.php中,添加一段代码,开启feed自动链接功能,代码如下:

add_theme_support( 'automatic-feed-links' );

步骤三:在模版文件中,添加一个订阅地址告诉用户:

<a href="<?php bloginfo('rss2_url');?>">rss订阅</a>

帮助文档:

中文官方参考文档:http://codex.wordpress.org/zh-cn:%E4%B8%BB%E9%A2%98%E7%89%B9%E6%80%A7

英文官方参考文档:http://codex.wordpress.org/Theme_Features

原文地址:https://www.cnblogs.com/tinyphp/p/6358555.html