Created
October 18, 2012 19:41
-
-
Save felipelavinz/3914346 to your computer and use it in GitHub Desktop.
sanitize data on "IN" clauses with wpdb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $menu_items = array(); | |
| foreach ( $menus[$menu] as $item ) $menu_items[] = $item['id']; | |
| $placeholders = implode(', ', array_fill(0, count($menu_items), '%s')); | |
| $query = "SELECT post_name, ID, post_title FROM $wpdb->posts WHERE post_name IN($placeholders)"; | |
| $results = $wpdb->get_results( $wpdb->prepare($query, $menu_items), OBJECT_K ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment