One way to achieve such effect would be to use wp_nav_menu_objects
hook.
function modify_home_in_nav_menu_objects( $items, $args ) {
foreach ( $items as $k => $object ) {
// you can also target given page using this if:
// if ( 'page' == $object->object && 2 == $object->object_id ) {
if ( 30 == $object->ID ) {
$object->title="<i class="fas fa-home"></i>";
}
}
return $items;
}
add_filter( 'wp_nav_menu_objects', 'modify_home_in_nav_menu_objects', 10, 2 );
PS. Should it really be fas
and not fa
in there?
Related Posts:
- How to add an arrow to menu items has submenus
- Change the footer text on the login page
- How to remove a metabox from menu editor page?
- Check if page parent has certain template
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- Find variables available at a given hook
- Getting my head round WordPress filter
- How To Change The Html of Products filtration sidebar in Woocommerce?
- How to set a custom path, for ajax image upload folder in admin?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- How to call function at the bottom of post using plugin?
- Run a filter when a walker runs
- Handling Body class based on Template
- Input type search in Menu
- Edit incorrect password message WordPress
- Add data attribute to each li in menu
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Remove metabox from WordPress menu editor page?
- Remove a div from RSS feed
- WordPress Gravatar filter is removing my custom attributes
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Unique icons next to each WordPress menu item
- Add item to top of menu using a filter in functions.php
- How to have different site identity logos on each page on Astra Theme [closed]
- Get the name of menu item with wp_nav_menu
- How to add aria role and schema markup to custom walker container
- Must filter functions receive all arguments passed to them?
- How to sort WooCommerce products page by latest in-stock items first?
- Filter wordpress posts without searching the keywords in the post content
- Variation prices breakdown only for single product page
- How to edit post meta data before publishing the post it self wordpress?
- Fatal error: Uncaught Error: Class ‘WP_Block_Styles_Registry’
- using filter and hook inside class
- add_filter() inside another add_filter()
- How to disable sub menu items from being created?
- Add class to all meta boxes for a custom post type
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- How to add custom checkout field in user details mail template
- For each loop will not append to the_content hook
- Assign new post author IF another user in custom field on post transition
- How to add different menu items on different menus?
- Is there a hook that I can use when a fatal error occurs?
- how to append ACF field data using one of the following filter/ hooks
- how to add a div inside wp_page_menu
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- Why in this WordPress theme I can’t see the Main Menu?
- Show login greeting above sub-menu links?
- Why can’t I add a custom image in my navigation?
- How to pass hook variable to function?
- Remove submenu item from list
- conditional: if is page, and all subpages
- wp nav menu: show submenu below li item
- How to tell if a user has gone in and created a menu
- Dynamic Menu drops pages?
- Class for Selected Menu using wp_nav_menu
- Remove the Tag from wp_nav_menu
- Menu not styling. New menus functionality giving me a headache
- Styling an “active” link outside of WordPress default menu
- How to create Loop code for Menu using WordPress?
- WordPress doesn’t load HTML
- Hard-coding a shortcode as the last menu item in primary navigation?
- Dynamic menu with custom post types
- How to internationalize header image?
- apply_filters with several different values?
- How can I modify this code to make the search box include tags and meta
- Add class to ul and li in wp_na
- User filter posts by year
- Nav Walker that shows only children and siblings of top level parent menu item
- save_post trigerred twice
- How to add a custom filter (by coding) before access one wordpress page ? And where to call the custom filter?
- how to changes mobile menu toggle breakpoint in WordPress
- How to display already created menus via php?
- Use a hook or filter, or overwrite this Gamipress function?
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- Generate a QR code when creating a new WordPress user
- Show related products by attribute based and certain conditions
- How to Create custom block for displaying information in content section which act like shortcode
- Replace a single variable with add_filter
- Adding an Anchor Link to a wordpress menu using WPBakery Page Builder
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
- How do I add a function to parent theme
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Display custom field value in woocommerce variable product via jQurey
- Filter ‘comment_notification_text’ not working
- Prevent header and footer from loading on specific pages with template or plugin
- Remove Author Links
- Add custom field on admin dashboard comments / reviews
- Adding markup to sub menu based on class
- Featured image in menu wordpres
- How to make only the valid active page of a multilevel menu active with – “.nav li.current-menu-item a”?
- How to run php code only for a specific widget on a page and not all widgets on that page?
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Contain multiple page templates in one PHP custom template file in WordPress?
- Show full post instead of excerpt
- Use wp_head hook on template page
- Replace jQuery with PHP or CSS for Customized WordPress wp_nav_menu
- Wp_Schedule_Event every few minutes doesn’t work
- Apply function.php filter only if url not has /amp/