WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Align menu on Admin Bar (3 posts)

  1. mienque
    Member
    Posted 11 months ago #

    Hello,
    I use this following code to add a login link for logout user

    function add_login_link( $meta = FALSE ) {
    	global $wp_admin_bar, $blog_id;
    	if ( is_user_logged_in() ) { return false; }
    	$wp_admin_bar->add_menu( array(
    		'id' => 'login_menu',
    		'title' => __( 'Log in or Sign up' ),
    		'href' => get_home_url( $blog_id, '/wp-login.php' ) )
    	);
    }
    add_filter( 'show_admin_bar', '__return_true' ); /* turn on adminbar for logged out users */
    add_action( 'admin_bar_menu', 'add_login_link', 15 );

    However, thi Log in or Sign up link was put on the left. How to move it to the end right?

  2. bcworkz
    Member
    Posted 11 months ago #

    Not 100% sure, but from the looks of things, you add 'parent' => 'top-secondary', to the add_menu() arguments array. top-secondary is a menu group which has float: right; CSS assigned to it.

  3. mienque
    Member
    Posted 11 months ago #

    Thank you very much,
    Your code works like a charm to align right my menu.

Reply

You must log in to post.

About this Topic

Tags