Skip to content

Instantly share code, notes, and snippets.

@n8finch
Created September 19, 2016 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n8finch/d093199f4abecdc146b74dc1ff5a87de to your computer and use it in GitHub Desktop.
Save n8finch/d093199f4abecdc146b74dc1ff5a87de to your computer and use it in GitHub Desktop.
filter-nav-menu-items-genesis-angular-gulp
add_filter( 'wp_setup_nav_menu_item', __NAMESPACE__ . '\filter_nav_menu_items', 1 );
function filter_nav_menu_items( $menu ) {
$post_type = ( $menu->object ); //gets post type
//if post type is a page, then create a new URL
if ( $post_type === 'page' ) {
$menu_url = $menu->url;
$new_url = '/pages' . str_replace( 'https://n8finch.dev/', '/', $menu_url );
$menu->url = $new_url;
}
return $menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment