Skip to content

Instantly share code, notes, and snippets.

@awsm-support
Created August 30, 2021 09:58
Show Gist options
  • Save awsm-support/381ac73e0347a6ef4af36dd7bdee2a44 to your computer and use it in GitHub Desktop.
Save awsm-support/381ac73e0347a6ef4af36dd7bdee2a44 to your computer and use it in GitHub Desktop.
WP Job Openings - Reset Job Views Count
<?php
/**
* NOTE: Please execute this function only once. After resetting the views, remove the whole code snippet.
*/
function awsm_jobs_reset_views_count() {
$args = array(
'post_type' => 'awsm_job_openings',
'post_status' => array( 'publish', 'expired', 'future', 'draft', 'pending' ),
'posts_per_page' => -1,
'fields' => 'ids',
);
$job_ids = get_posts( $args );
if ( ! empty( $job_ids ) ) {
foreach ( $job_ids as $job_id ) {
delete_post_meta( $job_id, 'awsm_views_count' );
}
}
}
add_action( 'init', 'awsm_jobs_reset_views_count' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment