PHP Snippet 1:
SELECT
postmeta.post_id
FROM
postmeta
INNER JOIN posts
ON (posts.ID = postmeta.post_id )
WHERE
postmeta.meta_key = '".$core_admin_values['listing_expiration']['key']."'
AND posts.post_status = 'publish'
AND postmeta.post_id =
(
SELECT
postmeta.post_id
FROM
postmeta
WHERE
postmeta.meta_key = 'listing_status'
AND postmeta.meta_value != 1
)
AND posts.post_type = '".$core_admin_values['listing_expiration']['taxonomy']."_type'
AND DATE(postmeta.meta_value) < DATE(NOW())";
PHP Snippet 2:
SELECT
postmeta.post_id
FROM
postmeta
WHERE
postmeta.meta_key = 'listing_status'
AND postmeta.meta_value != 1
PHP Snippet 3:
AND postmeta.post_id in
(
SELECT
postmeta.post_id ...
)
PHP Snippet 4:
$SQL = "SELECT ".$wpdb->prefix."postmeta.post_id FROM ".$wpdb->prefix."postmeta
INNER JOIN ".$wpdb->prefix."posts ON (".$wpdb->prefix."posts.ID = ".$wpdb->prefix."postmeta.post_id )
WHERE ".$wpdb->prefix."postmeta.meta_key = '".$core_admin_values['listing_expiration']['key']."'
AND ".$wpdb->prefix."posts.post_status = 'publish'
AND ".$wpdb->prefix."postmeta.post_id = (SELECT ".$wpdb->prefix."postmeta.post_id FROM ".$wpdb->prefix."postmeta WHERE ".$wpdb->prefix."postmeta.meta_key = 'listing_status' AND ".$wpdb->prefix."postmeta.meta_value != 1 LIMIT 1)
AND ".$wpdb->prefix."posts.post_type = '".$core_admin_values['listing_expiration']['taxonomy']."_type'
AND DATE(".$wpdb->prefix."postmeta.meta_value) < DATE(NOW())";
$expired_listings = (array)$wpdb->get_results($SQL);
PHP Snippet 5:
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);