Skip to content

Instantly share code, notes, and snippets.

@florieger
Created April 21, 2012 11:37
Show Gist options
  • Save florieger/2436725 to your computer and use it in GitHub Desktop.
Save florieger/2436725 to your computer and use it in GitHub Desktop.
Remove output of WordPress head
<?php // This File will be read by the wordpress engine, handle with care
// =============== Remove some output of the wp_head() function ===============
remove_action( 'wp_head', 'wp_generator' ); // Remove the WP version in the generator tag
remove_action( 'wp_head', 'feed_links', 2 ); // Remove the links to the general feeds: Post, Comment and Alternate feed
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Remove the links to the extra feeds such as category feeds
//remove_action( 'wp_head', 'rsd_link' ); // Remove the link to the Really Simple Discovery service endpoint, EditURI link
//remove_action( 'wp_head', 'wlwmanifest_link' ); // Remove the link to the Windows Live Writer manifest file
remove_action('wp_head', 'rel_canonical'); // Remove canonical link
add_filter('previous_post_rel_link', 'ac_remove_helper' ); // Remove previous link
add_filter('next_post_rel_link', 'ac_remove_helper' ); // Remove next link
// Helper function for remove actions
function ac_remove_helper($data) {
return false;
}
// Untestet stuff
//remove_action( 'wp_head', 'index_rel_link'); // Remove index link
//remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Remove relational links for the posts adjacent to the current post.
?>
@florieger
Copy link
Author

I have no idea, why the following implementation is not working (at least not for me):

remove_action('wp_head', 'previous_post_rel_link', 10, 0 );
remove_action('wp_head', 'next_post_rel_link', 10, 0 );

But I found the helper method solution, which works fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment