Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other [WordPress] What do you include in YOUR functions.php file?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #176114
    mikes02
    Participant

    I’m always curious what others include in every functions.php file when they build out a site, here are some defaults for me, some may be outdated by now:

    <?php
    // REMOVE JUNK FROM HEAD
    remove_action('wp_head', 'feed_links_extra', 3); // Displays the links to the extra feeds such as category feeds
    remove_action('wp_head', 'feed_links', 2); // Displays the links to the general feeds: Post and Comment Feed
    remove_action('wp_head', 'rsd_link'); // Displays the link to the Really Simple Discovery service endpoint, EditURI link
    remove_action('wp_head', 'wlwmanifest_link'); // Displays 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'); // prev link
    remove_action('wp_head', 'start_post_rel_link'); // start link
    remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); // Displays relational links for the posts adjacent to the current post.
    remove_action('wp_head', 'wp_generator'); // Displays the XHTML generator that is generated on the wp_head hook, WP version
    
    // ADD FAVICON TO HEADER 
    function blog_favicon(){echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('template_directory').'/favicon.ico">';}
    add_action('wp_head', 'blog_favicon');
    
    // REMOVE WORDPRESS DEFAULT LOGIN ERROR MESSAGES AND ADD CUSTOM
    add_filter('login_errors',create_function('$a', "return 'Login Information Incorrect. Please Try Again.';"));
    
    // REPLACE DEFAULT WORDPRESS LOGIN LOGO WITH CUSTOM LOGO
    function custom_login_logo() {echo '<style type="text/css">h1 a { background: url('.get_bloginfo('template_directory').'/images/logo-login.png) no-repeat}</style>';}
    add_action('login_head', 'custom_login_logo');
    
    // ADD TITLE TO LOGIN LOGO
    function change_wp_login_title(){return 'Title Here';}
    add_filter('login_headertitle', 'change_wp_login_title');
    
    // ADD POST THUMBNAILS
    if(function_exists('add_theme_support')){add_theme_support('post-thumbnails');}
    
    // MENUS
    if(function_exists('add_theme_support')){add_theme_support( 'menus' );}
    
    // Customize the footer in admin area
    function wpfme_footer_admin () {
        echo '<a href="http://urlhere.com/" target="_blank">Name Here</a>';
    }
    add_filter('admin_footer_text', 'wpfme_footer_admin');
    
    // Enqueue Main Stylesheet
    function main_styles()
    {
        wp_enqueue_style( 'style', get_stylesheet_uri() );
    }
    add_action( 'wp_enqueue_scripts', 'main_styles' ); 
    #176116
    Alen
    Participant

    I’m currently going over my project boilerplate. Here’s the functions.php file.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Other’ is closed to new topics and replies.