2

I want to change the url of the Wordpress 'Back to XXXX' on the wordpress url.

I've used this function to change the logo url, but there doesnt seem to be a footerurl reference.

add_filter( 'login_headerurl', 'custom_login_header_url' );
function custom_login_header_url($url) {
  return 'http://www.myurl.com/';
}

Any ideas how I can change this url with a filter? My wordpress installation is a micro-site sitting under a main site, which is why I want it to go to a different url that home_url.

3 Answers 3

2

Since this is not a standard feature you could achieve this with your own css and js you could add to the page like this

    <?php
    function custom_login() { 
    echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('template_directory').'/custom-login/custom-login.css" />'; 
    echo '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>'
    echo '<script type="text/javascript" src="'. get_bloginfo("template_url") . '/js/yourScript.js"></script>';
    }
    add_action('login_head', 'custom_login');
    ?>

change jquery url as wanted to get last version.

The div id where the link is in is called #backtoblog

you could change the innerhtml using javascript/jquery.

$('#backtoblog').html('<a href="http://gotomyblog.com">go back</a>');

or you could use css to get rid of it.

#backtoblog{display:none;}

like this.

enjoy

4
  • Hi, this sent me down the right path but there are a few problems with your answer. a) JS call is a CSS link b) No jQuery loaded (I load this aswell).
    – SMacFadyen
    Aug 14, 2012 at 14:08
  • yeah, my bad , copy paste nastyness. let me fix it.
    – woony
    Aug 14, 2012 at 14:21
  • Ok, I can accept it then. Cheers.
    – SMacFadyen
    Aug 14, 2012 at 14:24
  • should be better now, my bad for being messy.
    – woony
    Aug 14, 2012 at 14:32
1

Instead of adding so many files, which you don't need. Use plain ol' JavaScript for this.

/**
 * Change Back to URL on login.
 *
 * Change Back to Home URL on login page.
 *
 * @since 1.0.0
 */
function wpse61784_change_back_to_url() {
    ?>
    <script type="text/javascript">
        var backToBlog = document.getElementById( 'backtoblog' ).getElementsByTagName( 'a' )[0];
        backToBlog.setAttribute( 'href', 'https://NEW-URL.com/' );
        backToBlog.innerHTML='&larr; Back to NEW TEXT';
    </script>
    <?php
}

// Hook it.
add_action( 'login_footer', 'wpse61784_change_back_to_url' );

Cheers! 🎯

0

I've amended the above answer by @woony to include jQuery and outputted my function differently.

function custom_login() { 
    ?>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    <script src="<?php bloginfo('template_url'); ?>/js/custom-login.js"></script
<?php }
add_action('login_head', 'custom_login');

The custom-login.js

  $(function(){
        $('#backtoblog').html('<a href="http://xxx">&larr; Go back</a>');
  });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.