WPDB Placeholders and second argument for prepared statements
Just use %s for string and %d for digit replacements. Do not forget to use the proper esc_*() functions (use full text search for esc_ in the function reference). global $wpdb; $wpdb->show_errors = true; $wpdb->suppress_errors = false; ! defined( ‘DIEONDBERROR’ ) and define( ‘DIEONDBERROR’, true ); $sql = <<<SQL SELECT ID FROM {$wpdb->posts} WHERE post_type=”attachment” … Read more