Custom Walker anchor tag not inheriting attributes

This looks like just a misunderstanding about the canvas element – if a browser supports canvas, any elements you place inside a canvas simply won’t display, i.e. they’re fallback elements for browsers that don’t support the canvas element. (That inlcudes text nodes) I looked through the script and it looks fine – except for stuff … Read more

How to add a parameter to links in the nav menu?

To add a new attribute to your anchor link for the nav items concatenate $attribute variable with your required attribute. You have commended code just uncomment the code and use those $attributes = ! empty( $item->attr_title ) ? ‘ title=”‘ . esc_atta( $item->attr_title ) .'”‘ : ”; $attributes .= ! empty( $item->target ) ? ‘ … Read more

Loop through Navbar, Output Icons

There are 4 arguments that might help you with wp_nav_menu(): before – “(string) Text before the link text.” after – “(string) Text after the link text.” link_before – “(string) Text before the link.” link_after – “(string) Text after the link.”

Does WordPress create mobile menus automatically?

The default WordPress themes, from Twenty Eleven onwards, support varying degrees of responsive design, including menus, and any child themes will automatically inherit this behaviour, unless the child theme does something to override it. It is possible to create menus in your theme using wp_nav_menu that can then be hidden or displayed for various screen … Read more

No link on empty page in wp_list_pages

wp_list_pages() uses a walker named Walker_Page to render its output and this can be overridden. Below is a customized version of Walker_Page::start_el(). The code was first copied from the core, then a simple check was added before outputting the link. If a post does not have any content, then the title is wrapped in a … Read more

wp_get_nav_menu_items vs wp_nav_menu

wp_get_nav_menu_items function retrieves an array of menu items for given menu. But the menu is a hierarchy, so there is a need of creating some mechanism that will create that hierarchy based on list of menu items. On the other hand there already is wp_nav_menu, that will get items for that menu (using wp_get_nav_menu_items) and … Read more

Highlight the “Home” / “Blog” button while on main page

WordPress marks the currently displayed page in the menu with CSS classes .current-menu-item, .current-menu-parent, .current-menu-ancestor. Add the required styles to highlight items using these classes. Sample Menu: * Blog * First Category * Second Category * About * Contact When you open blog page, the corresponding menu item (“Blog“) has a class .current-menu-item. Similarly, when … Read more