I can’t find a way to add the log in link to the new theme of WordPress, Twenty Twelve.
I did find a lot of answers on the older theme, where they suggest to add some code in the functions.php file. However, this do not work for me.
Does anyone have a solution for this? You can see my homepage here: http://musikfest.dk/kursus/
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Filter wp_nav_menu_objects and add the link as item, similar to this answer.
add_filter( 'wp_nav_menu_objects', 't5_menu_log_link', 10, 2 );
/**
* Add a link to the nav menu.
*
* @wp-hook wp_nav_menu_objects
* @param array $sorted_menu_items Existing nav menu items
* @param object $args Nav menu arguments. 'add_loginout' must be TRUE
* @return array Nav menu items
*/
function t5_menu_log_link( $sorted_menu_items, $args )
{
$is_in = is_user_logged_in();
$link = new stdClass;
$link->title = __( $is_in ? 'Log Out' : 'Log In' );
$link->menu_item_parent = 0;
$link->ID = '';
$link->db_id = '';
$link->url = $is_in ? wp_logout_url() : wp_login_url();
$sorted_menu_items[] = $link;
return $sorted_menu_items;
}
Get it as plugin from GitHub.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0