Showing a logout link into a theme

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>
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.