go41

remove lines from your wp_head() function with a plugin

von Joern am 15. Jan. 2011 | Keine Kommentare

Switching themes and editing functions.php in each theme I didn’t like. There are always some lines in the WordPress header inside the ‚head‘ tag I do not want to display.
This is stuff like the

rel=’prev‘ and rel=’next‘ to display relational links adjacent to the current post

the Really Simple Discovery (RSD) link

the link to the Windows Live Writer manifest

the index link rel="index"

WordPress generator notice to display the version used

the links to the extra feeds such as category feeds
All these lines are generated by one line in header.php of most themes:
the function call wp_head()
It is not wise to remove this line from header.php as many plugins use it to load something.
So we have to remove each item we do not need by a function:

remove_action( ‚wp_head‘, ‚here_is_what_is_to_remove‘);
using one theme only you could put all these remove actions into your functions.php in the theme folder, like:

Code:

remove_action('wp_head', 'wp_generator'); // remove display of WordPress version
remove_action('wp_head', 'rsd_link'); // remove Really Simple Discovery Link
remove_action('wp_head', 'wlwmanifest_link');  // remove Windows Live Writer Link
remove_action( 'wp_head', 'feed_links_extra', 3 ); // remove Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // remove Display the links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'index_rel_link' ); // remove index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // remove prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // remove start link
remove_action ('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); // remove Display relational links for the posts adjacent to the current post. WP3xx ONLY!!

On one of my sites, http://themes.go41.de/ I use a theme switcher, so it would be required to edit each functions.php in each themes folder.
Using a plugin to remove items in your header does this for all themes in one single file. You can copy the code below to a file and call it headcallremover.php or anything you like, it just has to be a .php file.

This file you ftp into your wp-content/plugins/ folder, log into your admin, go to Plugins and activate ‚WpHeadcalls Disabler‚ plugin you should find there.
Here the code to copy and paste:

Code:

<?php
/*
Plugin Name: WpHead Calls Remover
Plugin URI: http://forum.go41.de
Description: removes listed calls from wordpress head, you are free to uncomment whatever you think you still need by adding // in front of lines
Version: 0.1.0
Author: joern
Author URI: http://www.go41.de
*/
remove_action('wp_head', 'wp_generator'); // remove display of WordPress version
remove_action('wp_head', 'rsd_link'); // remove Really Simple Discovery Link
remove_action('wp_head', 'wlwmanifest_link');  // remove Windows Live Writer Link
remove_action( 'wp_head', 'feed_links_extra', 3 ); // remove Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // remove Display the links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'index_rel_link' ); // remove index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // remove prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // remove start link
remove_action ('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); // remove Display relational links for the posts adjacent to the current post. WP3xx ONLY!!
?>

feel free to ask if there is a question
____________________
you find me on Google+, Twitter and Facebook

(von: Joern)

Sorry, no posts matched your criteria.

Autor:

Du findest mich auch auf Twitter und Facebook!

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.


Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.

weitere forum Beiträge: