Change Default WordPress Logout URL to a Custom URL

Change Default WordPress Logout URL to a Custom URL

WordPress themes and plugins output default logout URLs in many parts of your website like contents, comments, widgets, etc. You might want to replace or customize the output of the default logout URL if you have custom access rules for your WordPress login page.

There’s a filter available in WordPress core called logout_url to make this possible. You can change your website’s front-end or back-end logout URL output easily by modifying the filter.

HEY! You must have the slug of your custom logout link URL to apply this filter. If your custom logout URL is “”, then “logout” is the page slug.

Change Default WordPress Logout URL

To customize or change default WordPress logout link output everywhere, use the code snippet:

// Change WordPress logout url with a custom link
add_filter( 'logout_url', 'bydik_change_wp_logout_link', 10, 1 );
function bydik_change_wp_logout_link( $link ) {
    return home_url( '/logout/?redirect_to=' ) . get_permalink();

You might need to change /logout/ in this code if your logout page slug is different. After this, the default logout links of your site (both front-end & back-end) will be changed to the new one.

If you just want to change the URL on the front-end of your site, use the code snippet:

// Change WordPress front-end logout links
add_filter( 'logout_url', 'bydik_change_frontend_logout_link', 10, 2 );
function bydik_change_frontend_logout_link( $link ) {
    if ( ! is_admin() ) {
        return home_url( '/logout/?redirect_to=' ) . get_permalink();
    return $link;

HEY! Both functions will redirect users to the page they were in. If you want a homepage redirection, then change get_permalink() to get_home_url() in the code.

Adding code snippets for the first time? Don’t know where and how to add code snippets? We have an in-depth article on how to add code snippets to a WordPress site.

Have something to say? Please join in the comments and get a response within a quick time!

Leave a Reply

Your email address will not be published. Your comments must follow our guidelines.