Skip to content

Instantly share code, notes, and snippets.

@alidemirci
Created April 3, 2020 09:19
Show Gist options
  • Save alidemirci/fe24f5ffcc263c64cba42a33ebf84771 to your computer and use it in GitHub Desktop.
Save alidemirci/fe24f5ffcc263c64cba42a33ebf84771 to your computer and use it in GitHub Desktop.
add_filter( 'wp_nav_menu_objects', 'amc_filter_menu', 10, 2 );
/**
* Filters to remove Home Link on Front Page
*/
function amc_filter_menu( $objects, $args ) {
// Return Default Value if the Menu isn't Main Menu
// Replace "Navigation_location" with your target location
if ( 'Navigation_location' !== $args->theme_location ) {
return $objects;
}
// Detect the Menu which equeal site URL
foreach ( $objects as $key => $object ) :
if ( get_site_url( null, '/' ) === $object->url && is_front_page() || get_site_url() === $object->url && is_front_page() ) :
unset( $objects[ $key ] );
endif;
endforeach;
// Return the menu objects
return $objects;
}
@alidemirci
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment