Menu
-
You know you have the nav menu under the logo
I know you can change it so it’s above the logo, but is there a way to keep it where it is, but add an additional menu above the logo?
Possibly one where I can add a register/login link on?
-
Hi there,
The hard way (but free) would be to add HTML to the theme using one of the hooks: https://generatepress.com/knowledgebase/hook-list/
The easy way would be to use our Secondary Navigation add-on, which does it all for you.
Let me know if you need more info 🙂
I’ve got a custom shortcode plug in
This is my class
.login_menu { background-color: #333333; font-size: 10px; color: #FFFFFF; padding: 5px 5px 5px 5px; text-align: right; }This is my code
<div class="login_menu"> <table> <tr> <td><?php wp_register(); ?> / <?php wp_loginout(); ?></td> </tr> </table> </div>Which has been shortcoded to
[sc name="Top Menu Login"]So in my custom php I have
add_action( 'generate_before_header','rlmenu' ); function rlmenu() { echo do_shortcode( '[sc name="Top Menu Login"]' ); }Will this work?
OK I tried that and it looks a bit fat, like i’ve added too much padding.
Also the register and login/logout links I expected to appear aren’t appearing
also it’s not right aligned.
i changed padding: 5px 5px 5px 5px; to padding: px 1px 1px 1px; but that hasn’t made any difference in the slightest?
I wouldn’t suggest adding the table in there.
Something like this might be better:
<div class="login_menu"> <span><?php wp_register(); ?> / <?php wp_loginout(); ?></span> </div>Thanks tom that worked
i don’t think my register and login links work however because nothing gets displayed
Glad it worked.
That might have something to do with how you set the shortcode up – make sure all the function names are right.
<div class="login_menu"><?php wp_register(); ?></div>This is what i have at the moment but it’s not displaying a register link?
https://codex.wordpress.org/Navigation_Menus
Do I need to edit functions.php and add another menu in there?
You could if you wanted to add a menu in there.
As for the register link, make sure people are able to register, as it says at the top here: https://codex.wordpress.org/Function_Reference/wp_register
The “Register” link is not offered if the Administration > Settings > General > Membership: Anyone can register box is not checked.
The anyone can register box is ticked.
I only want to create a text link that says Register and a text link that says login. and then when you’ve logged in the login link changes to welcome john (logout) or whatever
add_action( 'generate_before_header','rlmenu' ); function rlmenu() { echo ' <span class="login_menu">'; wp_register('',''); if( is_user_logged_in() ) { $current_user=wp_get_current_user(); echo 'Welcome ' . $current_user->user_login . ' ('; wp_loginout(''); echo ')'; } else { wp_loginout(''); } echo '</span> '; }This seems to work but the class only covers the register and login bits and not the whole area?
Could it be cos i’m using span instead of divs?
The class is only surrounding the register and login bits as far as I can tell?
yeah i fixed it by changing span to div
Awesome 🙂
The topic ‘Menu’ is closed to new replies.
