run an update script on all past posts

Posted in: Newspaper
Post count: 101

Hello,

this is a very specific issue and likely more wordpress related than not but here goes.

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 ?

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);

I have been informed that I should “hijack” the page template mechanism that displays multiple posts, but since the theme is rather complex I’d like some help to know where exactly I should be looking.

we have been trying and experimenting but havent had a lot of succes thusfar so any help is greatly appreciated.

Post count: 20688
Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.