Foegje in Home-ikoan ta oan it WordPress Navigaasjemenu

home menu

We love WordPress and work with it virtually every day. The navigation menu that's been active in WordPress is incredible – a nice drag and drop feature that's easy to use. If your theme doesn't have a menu section where you can modify your menus, you need to find a new developer!

With the addition of our Ajax load, I wanted to reduce the size of the home link on the navigation menu and simply put a home icon. Adding an icon isn't an option via WordPress, though, so we had to add the functionality through our theme's functions.php file. I found a snippet online for de thúskoppeling tafoegje oan it menu... Ik moast it gewoan oanpasse om in werklike ôfbylding te brûken ynstee fan 'e tekstlink.

Foegje in Home Icon ta oan WordPress

add_filter ('wp_nav_menu_items', 'add_home_link', 10, 2); funksje add_home_link ($ items, $ args) {if (is_front_page ()) $ class = 'class = "current_page_item home-icon"'; oars $ class = 'class = "home-icon"'; $ homeMenuItem = ' '. $ args-> foar. ' '. $ args-> link_before. '  '. $ args-> link_after. ' '. $ args-> nei. ' '; $ items = $ homeMenuItem. $ items; werom $ items; }

This code adds a class to the image as well so that you can adjust it's location via your stylesheet.

ien reaksje

  1. 1

Wat tinksto?

Dizze side brûkt Akismet om spam te ferleegjen. Learje hoe't jo kommentaargegevens ferwurke wurde.