You can use preg_replace. In short, we define a matching $search parameter, then we replace it with what we want.
Here we will search for >Home< and >Listen<.
<?php
/**
* do_action( 'wp_loaded' )
* This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
* @link https://developer.wordpress.org/reference/hooks/wp_loaded/
*/
add_action( 'wp_loaded', function() {
function wp_custom_fontawesome_nav( $subject ) {
if( ! is_admin() ) {
$search = [
'/>Home</', // ... >Home< with the brackets, to be sure to target the right Home word
'/>Listen</', // ... etc.
// ... etc.
];
$replace = [
'><i class="fas fa-play-circle"></i><', // ... Our replacement for Home
'><i class="fas fa-drum"></i><', // ... Our replacement for Listen
// ... etc.
];
$subject = preg_replace( $search, $replace, $subject );
return $subject;
};
};
ob_start( 'wp_custom_fontawesome_nav' );
} ); ?>
Place that in somewhere in your function.php file.