Hi @heyjoecampbell,
Actually, we don’t provide custom code as it is beyond our support and we usually will let the community takes the part if the query involves custom code.
However, please try the following
function unlist_posts() {
$query = new WP_Query( array( 'post_type' => 'announcements', 'posts_per_page' => -1 ) );
$array_of_post_type_announcements = [];
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$post_id = get_the_ID();
array_push($array_of_post_type_announcements, $post_id );
}
}
$hidden_posts = update_option( 'unlist_posts', $array_of_post_type_announcements );
return $hidden_posts;
}
add_action( 'init', 'unlist_posts' );
You need to add the code to your child theme’s functions.php.
I hope it will help.
Kind regards,
Herman ??