Created
August 30, 2021 09:58
-
-
Save awsm-support/381ac73e0347a6ef4af36dd7bdee2a44 to your computer and use it in GitHub Desktop.
WP Job Openings - Reset Job Views Count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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