Skip to main content
3 of 3
added 9 characters in body
Buttered_Toast
  • 2.8k
  • 1
  • 8
  • 21

Using wp_logout_url() is your best choice.

You will need to create a <a> tag and in the href attribute output wp_logout_url()

<a href="<?= wp_logout_url('/'); ?>" title="Logout">Logout</a>

I passed / as an argument because after the user will click the link he will be redirected back to the homepage, you can change it to what ever you want

EDIT

Using code snippets you could create a shortcode and then use it, almost, where ever you want.

add_shortcode('bt_custom_logout_link', 'bt_custom_logout_link');
function bt_custom_logout_link ($atts) {
    $link = '<a href="' . wp_logout_url('/') . '" title="Logout">Logout</a>';
    return $link;
}

This function will register a new shortcode named bt_custom_logout_link, to use it you need to type it like this [bt_custom_logout_link]

Buttered_Toast
  • 2.8k
  • 1
  • 8
  • 21