Skip to content

Instantly share code, notes, and snippets.

View GLWalker's full-sized avatar
🤠

G.L.Walker GLWalker

🤠
  • WeTite
  • Texas
  • 02:25 (UTC -06:00)
View GitHub Profile
@kodie
kodie / wp_dropdown_users_datalist.php
Created April 23, 2021 18:08
Use a datalist in place of a select dropdown for wp_dropdown_users in WordPress
<?php
// Use a datalist in place of a select dropdown for wp_dropdown_users
add_filter('wp_dropdown_users', 'wp_dropdown_users_datalist');
function wp_dropdown_users_datalist($html) {
preg_match("/name='(.*?)'/", $html, $name);
preg_match("/id='(.*?)'/", $html, $id);
$html = str_replace(array('<select', '/select>'), array('<datalist', '/datalist>'), $html);
$html = preg_replace("/id='$id[1]'/", "id='$id[1]-list'", $html);
$html = preg_replace("/name='$name[1]'/", '', $html);