How can we run an update script on all past posts ?
-
hello
for our site we are creating an alphabetical index.
To achieve this we enter a (mostly) lastname in the custom field keyword, of which the first letter is stored in an additional field called alphabetical_letter.We have created a script that does this for any article we update manually. However since we have a large database we have no desire to do this for each single post… is there a way to achieve this for the whole database and make this script below run once for all posts ?
we have been trying and experimenting but havent had a lot of succes thusfar so any help is greatly appreciated.
function my_acf_update_letter( $value, $post_id, $field ) { $taxonomy = 'alphabetical_letter'; $first_letter = strtoupper(substr($value, 0, 1)); wp_set_post_terms( $post_id, $first_letter, $taxonomy ); // return return $value; } add_filter('acf/update_value/name=keyword', 'my_acf_update_letter', 10, 3);
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How can we run an update script on all past posts ?’ is closed to new replies.