Customize Subdirectory' s Login Page

Hello, I have created a custom login page for my website: .Now I am trying to create a custom login page for a subdirectory that has a different wordpress installation. The issue is that I cannot make the connection to the stylesheet . The following function is not working for the second installation

function my_custom_login() {
echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/login/custom-login-styles.css" />';}
add_action('login_head', 'my_custom_login');

I have already made a copy of the login folder that contains the stylesheet in my subdirectory and I tried changing




but nothing changed. What would you suggest?

  • James Morris
    • WordPress Enthusiast

    Hello Manos,

    I hope you are well today.

    According to the WordPress Codex page for get_bloginfo():

    ‘stylesheet_directory’ – Directory path for the active theme. An active child theme will take precedence over this value

    This means you would need to copy the folder and files into the active theme on that subsite installation.

    In order to make this more portable and to match where you’ve moved the files to, you should change the code to the following:

    function my_custom_login() {
    echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('url') . '/login/custom-login-styles.css" />';}
    add_action('login_head', 'my_custom_login');

    This will reference the main URL of your subdirectory site with the correct path appended to it. Also, this way ignores the currently active theme, thereby future-proofing your login page.

    See the following link for more information:

    I hope this clarifies a bit.

    Best regards,

    James Morris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.