Support » Themes and Templates » Add text to navigation bar Twenty Eleven theme

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Try it with this in your childtheme’s functions.php:

    add_filter( 'wp_nav_menu_items', 'add_telephone_number', 10, 2 );
    function add_telephone_number($items, $args) {
    
        return $items . '<li class="menu-item telephone">' . $args->before . 'tel: 456 777 8347' . $args->after .'</li>';
    }

    and change ‘tel: 456 777 8347’ to the correct number.

    And put this in your child theme’s stylesheet (style.css):

    #access li.telephone {
        color: #EEEEEE;
        display: block;
        line-height: 3.333em;
        padding: 0 1.2125em;
        text-decoration: none;
    }

    Thanks, you’re a star! One more question; how can I algin the phonenumber to the right?

    algin = align 😉

    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Try adding float: right; to the #access li.telephone css declaration and test it in all major browsers.

    Brilliant, thanks!

    Hello,

    I’ve tried this and I must be missing something because my phone number is not displaying in the nav bar. Any ideas?

    Code from fuctions.php

    add_filter( ‘wp_nav_menu_items’, ‘add_telephone_number’, 10, 2 );
    function add_telephone_number($items, $args) {

    return $items . ‘<li class=”menu-item telephone”>’ . $args->before . ‘tel: 999 999 9999’ . $args->after .”;
    }

    Code from css

    #access li.telephone {
    color: #ffffff;
    display: block;
    line-height: 3.333em;
    padding: 0 1.2125em;
    text-decoration: none;
    float: right;
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add text to navigation bar Twenty Eleven theme’ is closed to new replies.