我有一个自定义的发布时间,它有一个到期日期。通过获取package_type
pf post(每种包类型在到期前有不同的天数,称为“生存天数”),提取alive_days
, 并将其添加到post_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() ");
一个简单的var_dump
退货NULL
. 为什么这个代码不起作用?(可能有多种原因……)