The value for the value
key in the meta query is probably the cause of the problem.
'value' => get_post_meta( get_the_ID(), 'cancelled', true )
The get_post_meta
call actually retrieves the value of the meta key “cancelled” for the current post. So, in your current WP_Query
, you’re retrieving all posts with a paypal_recur_profile_status
equal to the value of the custom field “cancelled” of the current post.
If you want to get posts that have a profile status of Cancelled
, you should check value
to be “Cancelled”:
$args = array(
'post_type' => 'subscription',
'post_status' => 'publish',
'meta_key' => 'expiry',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'posts_per_page' => -1,
'ignore_sticky_posts'=> 1,
'meta_query' => array(
array(
'key' => 'paypal_recur_profile_status',
'value' => 'Cancelled'
)
)
);
Furthermore, caller_get_posts
was replaced by ignore_sticky_posts
in WordPress 3.1 (so I’ve replaced that), and you can omit the compare
key in the meta_query
, as that’s =
by default.