custom query wordpress code example
Example 1: wordpress custom php use wp query
if ( ! defined('ABSPATH') ) {
/** Set up WordPress environment */
require_once( dirname( __FILE__ ) . '/wp-load.php' );
}
global $wpdb;
$results = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_id = 1", OBJECT );
Example 2: wp query search
$query = new WP_Query( array( 's' => 'keyword' ) );