<?php add_action( 'init', function() { if ( empty( $_GET['update-expiry'] ) || ! current_user_can( 'administrator' ) ) { return; } $expiry_date = '2020-03-25'; $listings = get_posts( [ 'post_type' => 'job_listing', 'fields' => 'ids', 'post_status' => 'expired', 'posts_per_page' => -1, ]); foreach ( $listings as $listing_id ) { update_post_meta( $listing_id, '_job_expires', $expiry_date ); // Change the status of each post to publish $updated = wp_update_post( [ 'ID' => $listing_id, 'post_status' => 'publish' ] ); } wp_die( 'Listing expiry dates updated, you can close this window.' ); }, 250);
Den Code in die functions.php deines Child-Themes einfügen.
In Zeile 6 das Datum mit dem gewünschten Datum im Format JJJJ-MM-TT eingeben.
Danach deine URL wie folgt aufrufen.
https://www.deiteseite.de/?update-expiry=1
In Zeile 6 das Datum mit dem gewünschten Datum im Format JJJJ-MM-TT eingeben.
Danach deine URL wie folgt aufrufen.
https://www.deiteseite.de/?update-expiry=1