Add itemprop Schema.org Markup to li Elements in wp_nav_menu

To add attributes to the menu’s li elements, you’d have to write your own custom walker that extends the default Walker_Nav_Menu class (which is itself an extension of the Walker class). For more info: https://codex.wordpress.org/Class_Reference/Walker

But as itemprop=”url” should normally be added to anchor elements, you could use the nav_menu_link_attributes filter.

For example, as per the WP docs, adding this to your functions.php will add the attribute itemprop=”url” to your anchor elements within the list item elements of your menu:

function add_menu_atts( $atts, $item, $args ) {
  $atts['itemprop'] = 'url';
  return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_menu_atts', 10, 3 );