Not sure how and where you can create a custom button, but you can add such a link per filter: Add a filter function to 'wp_nav_menu_objects'
and insert the link where you need it.
Here is a basic example:
add_filter( 'wp_nav_menu_objects', 'wpse_46547_add_log_out_link', 10, 2 );
function wpse_46547_add_log_out_link( $sorted_menu_items, $args )
{
$link = array (
'title' => 'Log out',
'menu_item_parent' => 0,
'ID' => '',
'db_id' => '',
'url' => wp_logout_url()
);
$sorted_menu_items[] = (object) $link;
return $sorted_menu_items;
}
You should modify the code:
- Check if you are on the correct menu. For example require a class
has_log_out_link
for themenu_class
parameter onwp_nav_menu
and test$args->menu_class
. - I18n for the menu title. 😉
- Set
menu_item_parent
to a post ID other than0
if you need the link in a sub menu. - There are more parameters for the link, see my other answer to inspect those.