2016-01-12 108 views
5

如何删除/删除wordpress feed来自head标签的网址header.php如何删除/删除标题中的wordpress feed url?

例以下网址:

<link rel="alternate" type="application/rss+xml" title="Example Business &raquo; Feed" href="http://example.com/feed/"/> 
<link rel="alternate" type="application/rss+xml" title="Example Business &raquo; Comments Feed" href="http://example.com/comments/feed/"/> 
<link rel="alternate" type="application/rss+xml" title="Example Business &raquo; Home Page Live Comments Feed" href="http://example.com/home/feed/"/> 

我不希望使用任何插件一样。

回答

12

我最近有需要删除Feed url链接元素,并试图避免自定义核心WordPress函数以下解决方案的作品。

确保您的主题目录中有一个functions.php文件。如果不创建该文件并编辑该文件。以下几行将有助于从wp_head()函数中删除选择行:

<?php 
remove_action('wp_head', 'feed_links_extra', 3); // Display the links to the extra feeds such as category feeds 
remove_action('wp_head', 'feed_links', 2); // Display the links to the general feeds: Post and Comment Feed 
remove_action('wp_head', 'rsd_link'); // Display the link to the Really Simple Discovery service endpoint, EditURI link 
remove_action('wp_head', 'wlwmanifest_link'); // Display the link to the Windows Live Writer manifest file. 
remove_action('wp_head', 'index_rel_link'); // index link 
remove_action('wp_head', 'parent_post_rel_link', 10, 0); // prev link 
remove_action('wp_head', 'start_post_rel_link', 10, 0); // start link 
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // Display relational links for the posts adjacent to the current post. 
remove_action('wp_head', 'wp_generator'); // Display the XHTML generator that is generated on the wp_head hook, WP version 
?> 
+1

这是一个非常干净的解决方案。但请注意,如果您不使用自制主题或儿童主题,则这些更改将被下一个主题更新覆盖。为了防止这种情况,创建一个[儿童主题](https://codex.wordpress.org/Child_Themes)或者制作一个小插件。 –