I have a custom post time that has an expiration date. The expiration date is derived by getting the package_type
pf the post (each package type has a different number of days before expiration, referred to as "Alive days"), extracting the value for alive_days
, and adding that to the post_date
.
I'm wondering if there's a way to remove all the posts where the current date exceeds the expiration date.
$post_id = $post->ID; // get the post ID
$package_id = get_post_meta( $post_id, 'package_select', true ); // get the post's package
$transaction_price_pkg = $monetization->templ_get_price_info( $package_id, '' ); // get the package info
$alive_days = "+" . $transaction_price_pkg[0]['alive_days'] . " days"; // get the "alive days" of the given package
$expired_date = date('Y-m-d H:i:s',strtotime($alive_days, strtotime($post->post_date))); // calculate the expiration date
// Here's where I'm having trouble
$query = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}transactions WHERE {$expired_date >= NOW() ");
A simple var_dump
returns NULL
. Why doesn't this code work? (there can be multiple reasons...)