add_action('init', function() {
  $priority = 'top';

  $regex = '([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)';
  $location = 'index.php?lang=$matches[1]&pagename=$matches[2]&competicion=$matches[3]&temporada=$matches[4]&agrupacion=$matches[5]&extra=$matches[6]';
  add_rewrite_rule( $regex, $location, $priority );

  $regex = '([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)';
  $location = 'index.php?lang=$matches[1]&pagename=$matches[2]&competicion=$matches[3]&temporada=$matches[4]&agrupacion=$matches[5]';
  add_rewrite_rule( $regex, $location, $priority );

  $regex = '([^/]*)/([^/]*)/([^/]*)/([^/]*)';
  $location = 'index.php?lang=$matches[1]&pagename=$matches[2]&competicion=$matches[3]&temporada=$matches[4]';
  add_rewrite_rule( $regex, $location, $priority );

  $regex = '([^/]*)/([^/]*)/([^/]*)';
  $location = 'index.php?lang=$matches[1]&pagename=$matches[2]&competicion=$matches[3]';
  add_rewrite_rule( $regex, $location, $priority );

});

add_action('init','add_get_val');
function add_get_val() { 
    global $wp; 
    $wp->add_query_var('competicion'); 
	$wp->add_query_var('temporada'); 
	$wp->add_query_var('comparativa'); 
	$wp->add_query_var('agrupacion'); 
	$wp->add_query_var('extra'); 
}

function my_add_frontend_scripts() {
	wp_enqueue_script('jquery-ui', 'https://code.jquery.com/ui/1.13.2/jquery-ui.js', array('jquery'), '1.8.6');
	//Enqueue the jQuery UI theme css file from google:
	$wp_scripts = wp_scripts();

	wp_enqueue_style(
		'jquery-ui-theme-smoothness', //select ui theme: base...
		sprintf(
			'https://ajax.googleapis.com/ajax/libs/jqueryui/%s/themes/smoothness/jquery-ui.css',
			$wp_scripts->registered['jquery-ui-core']->ver
		)
	);

}
add_action('wp_enqueue_scripts', 'my_add_frontend_scripts');