ewp_logo_slant

Edinburgh WP

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

Menu

Skip to content
  • Contact

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' );
}

if ( in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) { require_once locate_template( 'INSERT_FILENAME_HERE.php' ); }

This entry was tagged login. Bookmark the permalink.

Post navigation

← How to stop WordPress loading styles on your login page
How to stop WordPress adding responsive images to your RSS feed →

Recent Posts

  • How to add a new Page Template to WordPress
  • How to remove your front page from WordPress search results
  • The best way to customise the categories widget in WordPress
  • You’ve created a custom post type, but WordPress says your posts can’t be found…
  • Removing page, post, tag, category and taxonomy IDs from the body_class in WordPress

Archives

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

Tags

body_class code css filters functions images jetpack login responsive rss search template theme twentythirteen

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • 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:

© 2019 EdinburghWP - Wordpress design and customisation