WordPress Themes Development Question:
Download Job Interview Questions and Answers PDF
Explain me how to run database Query in WordPress?
Answer:
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' "
);
<?php $wpdb->query('query'); ?>// Examples
$wpdb->query( "
UPDATE $wpdb->posts
SET post_parent = 7
WHERE ID = 15
AND post_status = 'static' "
);
Download WordPress Theme Development Interview Questions And Answers
PDF
Previous Question | Next Question |
Explain me how do I prevent my images from being hot-linked by another website? | Explain me how to Change the Length of the Default WordPress Excerpt? |