WordPress functions.php Boilerplate


/ Published in: PHP
Save to your folder(s)

I use this to toss all the junk from the header, add a favicon, remove useless admin elements, and block WordPress' ancient jQuery file from embedding.


Copy this code and paste it in your HTML
  1. <?php
  2. if (!is_admin()) wp_deregister_script('jquery');
  3. wp_deregister_script('l10n');
  4. if (function_exists('automatic_feed_links')) {
  5. automatic_feed_links();
  6. } else {
  7. return;
  8. }
  9. remove_action('wp_head', 'rsd_link');
  10. remove_action('wp_head', 'wp_generator');
  11. remove_action('wp_head', 'feed_links', 2);
  12. remove_action('wp_head', 'index_rel_link');
  13. remove_action('wp_head', 'wlwmanifest_link');
  14. remove_action('wp_head', 'feed_links_extra', 3);
  15. remove_action('wp_head', 'start_post_rel_link', 10, 0);
  16. remove_action('wp_head', 'parent_post_rel_link', 10, 0);
  17. remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
  18. function blog_favicon() {
  19. echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('wpurl').'/favicon.ico" />';
  20. }
  21. add_action('wp_head', 'blog_favicon');
  22. function theme_admin_bar_render() {
  23. global $wp_admin_bar;
  24. $wp_admin_bar->remove_menu('comments');
  25. $wp_admin_bar->remove_menu('appearance');
  26. }
  27. add_action( 'wp_before_admin_bar_render', 'theme_admin_bar_render' );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.