Skip to content

Instantly share code, notes, and snippets.

@trey8611
Created January 1, 2018 18:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trey8611/af5bd35d1550438e97ac14750e20c22d to your computer and use it in GitHub Desktop.
Save trey8611/af5bd35d1550438e97ac14750e20c22d to your computer and use it in GitHub Desktop.
<?php
function my_search_media_library( $image ) {
global $wpdb;
$all_images = array();
$query = "SELECT * FROM " . $wpdb->posts . " WHERE guid LIKE '%" . $image . "%'";
$results = $wpdb->get_results( $query );
if ( $results ) {
foreach ( $results as $result ) {
$all_images[] = basename( $result->guid );
}
}
return implode( ",", $all_images );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment