- This topic has 12 replies, 2 voices, and was last updated 3 years, 10 months ago by
Tom.
-
AuthorPosts
-
June 12, 2017 at 4:49 pm #332652
Jamal
Hi
I would like to add a Login/Logout link to the footer bar by adding a custom menu with this code added in code snippets. When the secondary navigation is set to below/above header the login/logout appears alright but not when i put the secondary nav in the footer bar. Anyway to get a Login/Logout link on my footer? Currently i just have copyright text and no footer widgets. ThanksAgressively support the kind of work you want to see. Buy it. Talk about it. Review it.
June 12, 2017 at 8:16 pm #332701Tom
Lead DeveloperLead DeveloperI believe you would have to register a new theme location: https://codex.wordpress.org/Function_Reference/register_nav_menus
Then update “secondary” in your code with whatever you named it.
Let me know if you need more info π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 13, 2017 at 11:57 am #333049Jamal
Seems not to be working. I registered new location with this
register_nav_menus( array( 'footer_menu' => 'Login menu', ) );
and replaced “secondary” with both “Login” and “Login menu”. Anyway i can use
generate_before_footer
to do something like below, having them left and right aligned respectively?Some plain text || Login
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
June 13, 2017 at 4:11 pm #333188Jamal
I took another option of editing the deafult meta widget so only login link remains and it works as far as i can tell. https://wordpress.org/support/topic/edit-meta-widget-in-theme-file/
Thanks
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
June 13, 2017 at 7:44 pm #333232Tom
Lead DeveloperLead DeveloperDid you put it inside the after_setup_theme hook?
add_action( 'after_setup_theme','tu_register_custom_menu' ); function tu_register_custom_menu() { register_nav_menus( array( 'footer_menu' => 'Login menu', ) ); }
Then you would have to apply your custom menu to that theme location in Appearance > Menus.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 14, 2017 at 1:26 am #333299Jamal
Doesn’t seem to be working even after putting it after_setup_theme hook. Below is full code i have
//Register custom menu add_action( 'after_setup_theme','jam_register_custom_menu' ); function jam_register_custom_menu() { register_nav_menus( array( 'footer_menu' => 'Login menu', ) ); } // Add login/logout to the custom menu function add_login_logout_register_menu( $items, $args ) { if ( $args->theme_location != 'Login menu' ) { return $items; } if ( is_user_logged_in() ) { $items .= '<li><a href="' . wp_logout_url() . '">' . __( 'Logga Ut' ) . '</a></li>'; } else { $items .= '<li><a href="' . wp_login_url() . '">' . __( 'Logga In' ) . '</a></li>'; } return $items; } add_filter( 'wp_nav_menu_items', 'add_login_logout_register_menu', 199, 2 );
I have added a few other items to the custom menu http://i.imgur.com/Qam0M9p.png
Added the custom menu widget to the footer bar http://i.imgur.com/zqa6dSW.png
But it doesn’t show on the site http://i.imgur.com/TsvEMAp.pngThanks for taking a look at this, would love to get it working using this method.
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
June 14, 2017 at 9:13 am #333508Tom
Lead DeveloperLead DeveloperIn the $args->theme_location check, you want to use: footer_menu
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 14, 2017 at 10:27 am #333559Jamal
No luck with that as well, Tom. Must be combination of footer bar and custom menu widget because even when using the secondary navigation as i was doing in first post it wasn’t working.
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
June 14, 2017 at 11:48 pm #333826Tom
Lead DeveloperLead DeveloperStrange – are those the only menu items you’re wanting to add, or do you want others in there as well?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 15, 2017 at 2:38 am #333865Jamal
Just a login/logout link.
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
June 15, 2017 at 10:55 am #334067Tom
Lead DeveloperLead DeveloperPerhaps just stick this into a text widget?: https://en-ca.wordpress.org/plugins/login-logout-shortcode/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 16, 2017 at 12:43 pm #334653Jamal
I had to mull over it but in the end i went with your plugin suggestion and it works great. Thanks !
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
June 16, 2017 at 8:08 pm #334798Tom
Lead DeveloperLead DeveloperNo problem! π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.