Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Last active March 11, 2021 19:38
Show Gist options
  • Save wpscholar/5026f5053c898a88c01d to your computer and use it in GitHub Desktop.
Save wpscholar/5026f5053c898a88c01d to your computer and use it in GitHub Desktop.
$wpdb->prepare() example
<?php
global $wpdb;
$query = $wpdb->prepare(
"SELECT * FROM {$wpdb->posts} WHERE post_type = %s",
$post->post_type
);
$results = $wpdb->get_results( $query );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment