Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Add CSS Class to a WordPress String

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #203058
    bill66742
    Participant

    The below code adds Register/ Login/ Logout options to the WordPress main navigation menu


    add_filter(‘wp_nav_menu_items’,’show_register_login_link’);
    function show_register_login_link($nav) {
    // The “Register” link is not offered if the Administration > Settings > General > Membership: Anyone can register box is not checked.
    return $nav.wp_register(“<li class=’menu-item’>”, ““, false).”<li class=’menu-item’>”.wp_loginout(get_site_url(), false).”“;
    }

    Can someone provide some insight on how I would go about adding a CSS class to the string in the above code? Then I would be able to float:right the string to show the Register/ Login/ Logout options to the far right of the WordPress main navigation. Thank you for your time I appreciate it.

    #203061
    Alen
    Participant

    Maybe

    wp_register('&lt;li class="menu-item wp-register-link"&gt;', '', false)

    &lt;li class="menu-item wp-logout-link"&gt;' . wp_loginout(get_site_url(), false)

    notice the additional classes wp-register-link and wp-logout-link

    Then just target them with CSS.

    Hope that helps
    Alen

    #203062
    bill66742
    Participant

    Thank you very much , Alen. I will begin working with your suggestions right now and update this. I really appreciate your time.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.