Apps Ballance Cash_2 Chat Checkout Click Code Cog_Wheels Compose_email Conference Contacts Earth Edit_File_1_ Email Email_2 File Folder_2 Gift Group Group_2 Help ID ID_2 Key Keys Laptop_Store Like_1_ Link Lock Log_Out Map Marketing Mobile_UI Navigation POS Partnership Profile Safe_2 Search_User Secure_Files Settings Share Shield Shield_2 Shopping_Cart Support_Male Trash Type_pin User_female User_male logo copy

Showing a logout link into a theme

Iain Poulson avatar
Iain Poulson Last updated on March 6, 2021

Showing a logout url into a theme can be done with the 
wp_logout_url() function. This function can be placed anywhere into your theme files and accepts a custom url as optional parameter.

If the redirect parameter is not used, users will automatically be redirected to the page you’ve selected into the settings panel.

Example usage: logout and redirect to current page.

<a href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>">
  <?php _e('Logout', 'wpum'); ?></a>

Example usage: logout and redirect to another page by ID

<a href="<?php echo esc_url( wp_logout_url( get_permalink( 5 ) ) ); ?>">
  <?php _e('Logout', 'wpum'); ?></a>
WP User Manager logo

Get Started with the Best WordPress Membership Plugin Today

Connect, Manage and Build your Membership Site

Need more help?

If you still didn't find an answer you can always contact us

Submit a ticket