• joelr99

    (@joelr99)


    How can I add spans inside the link tags in the navigation menu using functions.php?

    I can code HTML and CSS but not php, I think themes should be made easier for designers when needing to create custom functions and features, because adding spans inside links should be so easy.

    Could I have the exact code that goes in function.php please

    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    (@esmi)

    Why do you need these spans? I’ve found that it’s possible to style just about any type of navigation menu using the markup and classes already provided by WP.

    BAC

    (@bac-1)

    joelr99

    I suspect you are looking to create speaking navigation i.e. text below the menu items on the nav.

    Two quick and dirty options:

    1. if you are using WP 2.9x use the excellent page lists plus plugin and each individual page has a option for navigation text, just add the spans after the menu text. i.e. home <span>about me</span>

    2. wp 3.0 – same idea, but just add the spans after the menu text using the inbuilt menus tool under appearance. You would need to add some code to your thematic child theme’s functions.php file to support the wp 3.0 menu system.
    see: http://programming.thematic4you.com/2010/03/how-to-test-wp_nav_menu-with-thematic/

    I think there is a SVN copy of thematic which supports wp 3.0 menus.

    If you want to get wp 3.0 install the beta tester plugin and upgrade to bleeding edge nightlies – but I wouldn’t recommend this for production.

    There is probably a less dirty function you can add to functions.php but these methods seems the easiest option for a PHP beginners. Its how i did it.

    Hope this helps
    BAC

    Thread Starter joelr99

    (@joelr99)

    I needed the spans to add extra images to background of the links.

    I found a bit of script to create the spans I needed:

    <?php wp_list_pages(‘link_before=<span>&exclude=26&title_li=&link_after=</span>’); ?>

    Which gives me:
    a title="Who we are" href="#"><span>Who we are</span></a>

    But I did actually find a way to add 2 images to the background using just the li and ‘a’ but I kept the spans in there in case I need.

    Thanks BAC for the info about WP 3.0 I will have a look into those ideas.

    Cheers guys

    Bac thanks for your comment, used your #2 method worked perfectly for me

    BAC, me too! Your simple method for WP 3.x worked for me… Thanks 😉

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Add span to navigation links’ is closed to new replies.