ewp_logo_slant

Edinburgh Word Press

WordPress development, customisation and jiggery-pokery from Edinburgh, Scotland

Menu

Skip to content
  • Contact

Tag Archives: login

Make WordPress load a functions file only on a login page

Posted on September 23, 2016 by Dave Fitch

I’m a big fan of modularising functions and only loading resources when needed. This snippet should be in your functions.php file and will only load an include file if a visitor is on the login or registration page. You can then squirrel your functions that customise the login experience or style it with CSS away here.

if ( in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) {
	require_once locate_template(	'INSERT_FILENAME_HERE.php' );
} 
Posted in wordpress | Tagged login | Leave a comment

How to stop WordPress loading styles on your login page

Posted on September 22, 2016 by Dave Fitch

WordPress – or should I say JetPack – has a lovely habit of loading a large amount of cruft that you may not want on your page. After the recent WP 4.6.x update I found the custom login page on one of my sites didn’t load properly anymore, because all the custom css was being over-ridden by css files WP was injecting at page load. This function stops this injection:

add_action( 'login_init', function() {
    wp_deregister_style( 'login' );
    wp_register_style( 'login', "" );
    wp_deregister_style( 'buttons' );
    wp_register_style( 'buttons', "" );
    wp_deregister_style( 'l10n' );
    wp_register_style( 'l10n', "" );
    wp_deregister_style( 'forms' );
    wp_register_style( 'forms', "" );
    wp_deregister_style( 'dashicons' );
    wp_register_style( 'dashicons', "" );
} );
Posted in wordpress | Tagged css, jetpack, login | Leave a comment

Post navigation

Recent Posts

  • The three places you need to change urls to actually update your WordPress site’s url
  • WP multisite, http, and https
  • Why don’t my custom taxonomies show up in WordPress’s post edit pages?
  • Posts not loading in the WordPress app?
  • Debugging WordPress Media imports

Archives

  • May 2023
  • September 2020
  • July 2020
  • December 2019
  • November 2019
  • October 2016
  • September 2016
  • May 2013
  • April 2013
  • December 2012
  • September 2012
  • August 2012

Categories

  • multisite
  • wordpress

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Contact us:

Online form +44 78 76 78 6316

Paper mail:

114 Blackford Avenue, Edinburgh, Scotland, EH8 9HH

Follow us:

twitter RSS mailing list

Content:

© 2025 EdinburghWP - Wordpress design and customisation