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

    (@keesiemeijer)

    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;
    }

    Thread Starter TimoElshof

    (@timoelshof)

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

    Thread Starter TimoElshof

    (@timoelshof)

    algin = align ??

    Moderator keesiemeijer

    (@keesiemeijer)

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

    Thread Starter TimoElshof

    (@timoelshof)

    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.