• hi
    i writing this code for expire post:

    add_action( 'expired_post_delete', 'delete_expired_posts' );
    function delete_expired_posts() {
    	$todays_date = time();
    
    	$the_query = new WP_Query('post_type=post');
    	while ( $the_query->have_posts() ) : $the_query->the_post();
    
    		$getmyvar = get_post_meta( get_the_ID(), 'getdateexpire', true );
    		if(!empty($getmyvar)){
    
    			if ( $getmyvar < $todays_date) {
    					$my_post = array(
    						'ID' => get_the_ID(),
    						'post_status' => 'pending',
    					);
    					wp_update_post( $my_post );
    			}
    
    		}
    
    	endwhile;
    	wp_reset_postdata();
    
    }

    now problem is when i add this in function.php , site was slow loaded.
    and another problem is , add_action() It does not work and must add this delete_expired_posts();
    What is the problem?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘expiration of contents with meta_post’ is closed to new replies.