Last active
January 15, 2025 15:50
-
-
Save nickpish/b2604e8032aba47b8d6fe37df6d96100 to your computer and use it in GitHub Desktop.
Function to update post meta for Personnel posts w/ BNFW plugin
This file contains hidden or 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 | |
function wes_update_personnel_notifications() { | |
// set args to query all Personnel posts | |
$args = array( | |
'post_type' => 'personnel', | |
'post_status' => 'any', | |
'posts_per_page' => -1, | |
); | |
$personnel_posts = get_posts( $args ); | |
foreach ( $personnel_posts as $post ) { | |
$post_id = $post->ID; | |
// update override field | |
if ( metadata_exists( 'post', $post_id, '_bnfw_override_23939' ) ) { | |
update_post_meta( $post_id, '_bnfw_override_23939', true ); | |
} | |
// update enable notification field | |
if ( metadata_exists( 'post', $post_id, '_bnfw_enable_23939' ) ) { | |
update_post_meta( $post_id, '_bnfw_enable_23939', true ); | |
} | |
} | |
} | |
add_action( 'init', 'wes_update_personnel_notifications' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment