• Hi, i have my wordpress in a dns sub domain so i want to change the “back to” link on the login to my main site.

    I have found several articles as well as i read the link in the general settings that talks about setting it up as part of your main site..

    However that is way too involved im not wanting to do that. I just want to change the link without having to do all that as well.

    I have changed the value in settings to my main site and it does change the link but i am afraid it will mess up my site because i did not do all the other stuff listed here.

    https://codex.www.ads-software.com/Giving_WordPress_Its_Own_Directory

    can i just change the link without breaking anything?

    thanks ??

    • This topic was modified 6 years, 5 months ago by durangod2.
Viewing 3 replies - 1 through 3 (of 3 total)
  • WordPress uses home_url() to generate the link which has a filter hook of the same name. You can check against the global $pagenow to ensure it only runs on the wp-login.php page:

    /**
     *  Modify the wp-login.php 'Back to' URL
     * 
     * @param String $url
     * 
     * @return String $url
     */
    function prefix_home_url( $url ) {
    
    	global $pagenow;
    
    	if( 'wp-login.php' === $pagenow ) {
    
    		$url = 'https://www.ads-software.com/support/topic/change-back-to-link-on-login/';
    
    	}
    
    	return $url;
    
    }
    add_filter( 'home_url', 'prefix_home_url' );

    You could put this into a MU plugin, normal plugin, or themes functions.php and it should work.

    Thread Starter durangod2

    (@durangod2)

    Hi, thanks for the reply and the information.. I did notice when i changed the value in settings. Then clicked on the link in my main site to go to WP, it took me right back to the main site, so its just redirecting it back.

    The way you advised to do this above will bypass that correct, so it wont loop back on access (if i leave the settings value at default which is wp)?

    ??

    It won’t loop back on access. Whenever you log in WordPress uses a different hook to handle login redirects. The two setting values in WP Admin should probably be the sa3me values.

    My above code simply overwrites any calls to home_url() whenever viewing the wp-login.php page, which is only the “Back to XYZ” url.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change -back to- link on login’ is closed to new replies.