Custom login with sage 9

I would like to add a custom login page to my current project. I am using sage 9 beta 4.
I want to use login_enqueue_scripts hook inside the theme. Can anyone please tell where should I add this hook? is it the setup.php file?

Wherever you prefer really, either setup or filters works!

1 Like

I have already tried it with setup.php. Can you please let me know if I am missing something here?

//login scripts
function my_login_stylesheet()
    wp_enqueue_style('sage/login.css', asset_path('styles/login.css'), false, null);
add_action( 'login_enqueue_scripts', 'my_login_stylesheet' );

I have added a new entry to the config.json and it’s outputting the login.css to dist/styles directory properly from login.scss.

I think it would make “more sense” to put it in admin.php, since it’s admin related.

Here’s my current code for including a custom style for the login page, located in admin.php:

add_action('login_enqueue_scripts', function () {
}, 100);

(I actually include the same css file for the login and the dashboard areas)

1 Like

You’re not passing the namespace correctly. Either use the namespace like this, or follow the other actions and filters in the theme and use anonymous functions.


anonymous function worked for me. Thanks mate!

Yes, it must have been that! I used an anonymous function following the previous comment. Thanks for your advice mate. I am quite new to both wordpress and sage, so I’ll investigate this namespace thing further.

1 Like