• Resolved formy808

    (@formy808)


    Hi, I’ve made the changes described in this post developed by @acub. I like it but I want to go further by having the logo be part of the navigation bar instead of above it. Basically I want the logo centered with the menu items floating to the left and right of the logo. So if I had 6 items in my menu it would look like this:

    menu1 menu2 menu3 LOGO menu4 menu5 menu6

    With everything being centered, of course. I’m new to this theme and just learning, so any pointers to get me started will help.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The simplest way to achieve this is to add a custom link to your menu and replace it with your logo image. Put a slash (/) in URL box and “replace-me-with-logo” in “Link title” box. The menu will create something like this:

    <li id="menu-item-519" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-519"><a title="Homepage" href="/">replace-me-with-logo</a></li>

    Now all you need to do is run a preg_replace on the function that generates your menu and replace replace-me-with-logo with your img tag (your logo). The replacement function would look like this and needs to be added in functions.php of your child theme:

    add_filter('tc_navbar_display', 'replace_custom_link_with_logo');
    function replace_custom_link_with_logo($output) {
    $html = '<img src="/path-to-your-logo-image" alt="your_company_name" />';
    /* Ofcourse, you will need to replace "/path-to-logo-image" with the
     * actual path to your image file and "your_company_name" with your
     * company or website name... Make sure there is no unescaped single
     * quote anywhere inside the $html variable.
     */
    return preg_replace('/replace-me-with-logo/', $html, $output);
    }

    Don’t forget to prevent the output of the normal logo:

    add_filter('tc_logo_title_display', 'prevent_output_of_logo');
    function prevent_output_of_logo($output) {
    return;
    }

    Haven’t tested it, but it should work. If you have any trouble with it, get back here and I’ll make some tests and see what I missed. If it works, please mark it as resolved.

    Thread Starter formy808

    (@formy808)

    Thanks @acub! That’s not how I was trying to go about it, but your solution is much simpler, and works 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘logo centered in navbar with menu items floating to left and right.’ is closed to new replies.