Answers

Question and Answer:

  Home  WordPress Theme Development

⟩ Explain me how to run database Query in WordPress?

The $wpdb->query function allows you to execute any SQL query on the WordPress database. It is best to use a more specific function. Check sample code below for SELECT query.

<?php $wpdb->query('query'); ?>// Examples

$wpdb->query( "

UPDATE $wpdb->posts

SET post_parent = 7

WHERE ID = 15

AND post_status = 'static' "

);

 172 views

More Questions for you: