wpdb query code example
Example 1: wordpress wpdb
get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_id = 1", OBJECT );
Example 2: wordpress execute query
global $wpdb;
$result = $wpdb->get_results( "SELECT * FROM wp_usermeta WHERE meta_key = 'points' AND user_id = '1'");
print_r($result);
Example 3: wp query
have_posts() ) {
echo '';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '- ' . get_the_title() . '
';
}
echo '
';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
Example 4: wpdb wordpress
global $wpdb;