Dear Sir/Madam,
Not sure whether the query is too complicated
$current_date = date('Y-m-d 0:0:0', strtotime("+8 hours", time()));
$end_time = strtotime('+1 day', strtotime($current_date) ) - 1;
$args = array (
'post_type' => 'member',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'wpcf-scheduled-to-pay',
'value' => '0',
'type' => 'numeric',
'compare' => '=',
),
array(
'key' => 'wpcf-uprise-next-bill-date',
'value' => array(strtotime($current_date), $end_time),
'type' => 'numeric',
'compare' => 'BETWEEN',
),
array(
'relation' => 'OR',
array(
'relation' => 'OR',
array(
'relation' => 'AND',
array(
'key' => 'wpcf-termination-date',
'value' => '',
'type' => 'numeric',
'compare' => '='
), // query if termniation-date is empty
array(
'key' => 'wpcf-termination-date',
'compare' => 'EXISTS'
) // query if terminsation-date is existed
), // query if post updated from dashboard without termniation-date value
array( // query if post updated from CRED form without termniation-date value
'key' => 'wpcf-termination-date',
'compare' => 'NOT EXISTS'
) // query if termination-date is not existed
),
array( // query if wpcf-termination-date has value later than today
'key' => 'wpcf-termination-date',
'value' => strtotime($current_date),
'type' => 'numeric',
'compare' => '>=',
)
)
)
);
I import thousand of record using WPIMPORT, I use below code to update 10 records
update_post_meta($post->ID, 'wpcf-uprise-next-bill-date', strtotime(date('Y-m-d 13:0:1', strtotime("+8 hours"))));
update_post_meta($post->ID, 'wpcf-termination-date', strtotime(date('Y-m-d 13:0:1', strtotime("+10 days"))));
10 records can't be queried, if I manually update the record from backend, records can be queried. What is the problem to the custom post.
I tried to do below code
function my_update_posts() {
//$myposts = get_posts('showposts=-1');//Retrieve the posts you are targeting
$args = array(
'post_type' => 'post',
'numberposts' => -1
);
$myposts = get_posts($args);
foreach ($myposts as $mypost){
$mypost->post_title = $mypost->post_title.'';
wp_update_post( $mypost );
}
}
add_action( 'wp_loaded', 'my_update_posts' );
but not work, only manually update the post then can solve.