Skip to content

Instantly share code, notes, and snippets.

@lislis
Created June 6, 2023 11:49
Show Gist options
  • Save lislis/0447f93c2f7ef8b45b88b3c82dd06638 to your computer and use it in GitHub Desktop.
Save lislis/0447f93c2f7ef8b45b88b3c82dd06638 to your computer and use it in GitHub Desktop.
Add "Login with Steady" as link to WP menu
/**
* For when you want the Steady login button as a proper link in your Wordpress menu.
* Assumes that you have the Steady WP plugin installed https://wordpress.org/plugins/steady-wp/
*/
add_filter('wp_nav_menu_items', 'add_steady_login_menu_function', 10, 2);
function add_steady_login_menu_function( $nav, $args ) {
// replace 'menu-location' with the name of your menu location
// you can find all menu locations in the 'register_nav_menus' function in your functions.php
if( $args->theme_location == 'menu-location' ) {
// putting together the link according to Steady integrations documentation
// notice that here we put the link as first link in the menu, but you can swap the order of course
return '<li><a class="steady-login-button" data-size="medium" data-language="en" style="display: none;"></a></li>'.$nav;
}
// if this is any other menu, we just return the menu
return $nav;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment