Deleting old expired jobs

Note: All code examples on this site are provided for developer reference/guidance only and we cannot guarantee that they will always work as expected. Our support policy does not include assistance with modifying or debugging code from any code examples, and they may be changed or removed if we find they no longer work due to changes in our plugins.

Note: this snippet works by moving expired jobs to the trash.  Once in the trash, WordPress takes over, and deletes trash by default after 30 days.   This snippet does not automatically,  upon expiration,  delete expired jobs.

Unlike old ‘previews’, expired jobs are not deleted by default. But you can enable this functionality using a quick snippet in your theme’s functions.php file (or using a functionality plugin):

// This will make sure expired jobs are deleted after XX days
add_filter( 'job_manager_delete_expired_jobs', '__return_true' );

// The default is 30 days, but you can change this with the following
add_filter( 'job_manager_delete_expired_jobs_days', 'change_job_manager_delete_expired_jobs_days' );

function change_job_manager_delete_expired_jobs_days() {
   return 30; // change this to the number of days you desired

If enabled, expired job listings will be deleted after job_manager_delete_expired_jobs_days days which defaults to 30. Cleanup will be done daily via a cron job.

If you’d like to change the default 30 days setting, the Trash status page on provides some solutions.

Code Snippets Documentation