ID); //make title lowercase $endpointTitleLowercase = strtolower($endpointTitleBase); //Make alphanumerice (remove all other characters) $endpointTitleSpecialChar = preg_replace("/[^a-z0-9_\s-]/", "", $endpointTitleLowercase); //Clean up multiple dashes or whitespaces $endpointTitleMultiWhitespace = preg_replace("/[\s-]+/", " ", $endpointTitleSpecialChar); //Replace whitespaces with dashes $endpointTitle = preg_replace("/[\s_]/", "-", $endpointTitleMultiWhitespace); $endpointURL = get_site_url().'/wp-json/custom-routes/v1/'.$endpointTitle; $customEndpoint = ''.$endpointURL.''; echo $customEndpoint; } } ?>