如何从 header.php
中的 head
标记中删除/移除 wordpress feed
网址?
以下 URL 示例:
<link rel="alternate" type="application/rss+xml" title="Example Business » Feed" href="http://example.com/feed/"/>
<link rel="alternate" type="application/rss+xml" title="Example Business » Comments Feed" href="http://example.com/comments/feed/"/>
<link rel="alternate" type="application/rss+xml" title="Example Business » Home Page Live Comments Feed" href="http://example.com/home/feed/"/>
我不想使用任何插件。
最佳答案
我最近需要删除 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
?>
关于php - 如何删除/删除标题中的 WordPress feed url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34750148/