| Server IP : 198.244.165.102 / Your IP : 216.73.216.218 [ Web Server : nginx/1.24.0 System : Linux modovh-ub-01 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64 User : colleary ( 1011) PHP Version : 8.3.23 Disable Function : NONE Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/midwest/public_html/ |
Upload File : |
<?php
require_once('wp-load.php');
function move_obituaries_to_past_death_notices() {
// Get the current date and subtract 7 days
$date_7_days_ago = date('Y-m-d', strtotime('-7 days'));
// Query for obituaries that are published before 7 days and assigned to 'death-notices'
$args = array(
'post_type' => 'obituaries',
'posts_per_page' => -1, // Get all posts
'post_status' => 'publish',
'date_query' => array(
array(
'before' => $date_7_days_ago,
'inclusive' => true,
),
),
'tax_query' => array(
array(
'taxonomy' => 'obituary-categories',
'field' => 'slug',
'terms' => 'death-notices', // Filter by 'death-notices' category
'operator' => 'IN',
),
),
);
$query = new WP_Query($args);
// Check if there are any obituaries
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
// Get the post ID
$post_id = get_the_ID();
// Get current terms assigned to the post in the 'obituary-categories' taxonomy
$current_terms = wp_get_post_terms($post_id, 'obituary-categories', array('fields' => 'slugs'));
// If 'death-notices' is assigned, remove it and assign 'past-death-notices'
if (in_array('death-notices', $current_terms)) {
// Remove 'death-notices' term
wp_remove_object_terms($post_id, 'death-notices', 'obituary-categories');
// Set the new term 'past-death-notices'
wp_set_post_terms($post_id, 'past-death-notices', 'obituary-categories', true);
}
}
}
// Reset post data
wp_reset_postdata();
}
// Run the function directly
move_obituaries_to_past_death_notices();
?>